Skip to content

Commit 6ac4f37

Browse files
committed
country it as default, style issues, checking table layout
1 parent 107cd05 commit 6ac4f37

7 files changed

Lines changed: 59 additions & 20 deletions

File tree

editor/src/app/components/editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default class Index extends Component {
8181
async componentDidMount() {
8282
await this.initData();
8383
this.switchLang("eng");
84+
this.switchCountry("it");
8485
}
8586

8687
async initData(country = null) {

editor/src/app/components/sidebar.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from "react";
22
import { connect } from "react-redux";
33
import copy from "copy-to-clipboard";
4+
import validator from "validator";
45
import { notify } from "../store/notifications";
56
import { APP_FORM } from "../contents/constants";
67
import img_x from "../../asset/img/x.svg";
@@ -51,6 +52,17 @@ export default class sidebar extends Component {
5152
const { onLoad, onReset } = this.props;
5253
let { remoteYml } = this.state;
5354
this.showDialog(false);
55+
56+
if (!remoteYml || !validator.isURL(remoteYml)) {
57+
this.props.notify({ type: 1, msg: "Not a valid url" });
58+
}
59+
60+
let ext = remoteYml.split(/[. ]+/).pop();
61+
if (ext != "yml" && ext != "yaml") {
62+
this.props.notify({ type: 1, msg: "File type not supported" });
63+
return;
64+
}
65+
5466
onReset();
5567

5668
let yaml = null;
@@ -72,7 +84,7 @@ export default class sidebar extends Component {
7284
}
7385
// let ext = files[0].name.split(".")[1];
7486
let ext = files[0].name.split(/[. ]+/).pop();
75-
if (ext != "yml") {
87+
if (ext != "yml" && ext != "yaml") {
7688
this.props.notify({ type: 1, msg: "File type not supported" });
7789
return;
7890
}
@@ -98,15 +110,15 @@ export default class sidebar extends Component {
98110
});
99111
let blobURL = window.URL.createObjectURL(blob);
100112
let tempLink = document.createElement("a");
101-
tempLink.style="display:none";
102-
tempLink.download= "pubbliccode.yml";
113+
tempLink.style = "display:none";
114+
tempLink.download = "pubbliccode.yml";
103115
tempLink.href = blobURL;
104116
tempLink.setAttribute("download", "pubbliccode.yml");
105117
document.body.appendChild(tempLink);
106118
tempLink.click();
107-
setTimeout(function(){
108-
document.body.removeChild(tempLink);
109-
window.URL.revokeObjectURL(blobURL);
119+
setTimeout(function() {
120+
document.body.removeChild(tempLink);
121+
window.URL.revokeObjectURL(blobURL);
110122
}, 1000);
111123
}
112124

@@ -146,7 +158,14 @@ export default class sidebar extends Component {
146158
</div>
147159
)}
148160
{!(fail && errors) && (
149-
<div className="sidebar__code"><pre><code>{'\n'}{yaml}</code></pre></div>
161+
<div className="sidebar__code">
162+
<pre>
163+
<code>
164+
{"\n"}
165+
{yaml}
166+
</code>
167+
</pre>
168+
</div>
150169
)}
151170
</div>
152171

@@ -161,6 +180,7 @@ export default class sidebar extends Component {
161180
<input
162181
id="load_yaml"
163182
type="file"
183+
accept=".yml, .yaml"
164184
style={{ display: "none" }}
165185
onChange={e => this.load(e.target.files)}
166186
/>

editor/src/app/editor_generator_schema.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,17 @@
9292
"definitions": {
9393
"publiccode-yaml-version": {
9494
"title": "publiccode-yaml-version",
95-
"type": "array",
96-
"uniqueItems": true,
97-
"items": {
98-
"type": "string",
99-
"title": "Version",
100-
"enum": ["developmnet", "0.1"]
101-
},
95+
"label": "publiccode-yaml-version",
96+
"type": "string",
97+
"enum": ["developmnet", "0.1"],
10298
"description":
10399
"This key contains the version of the publicode definition.",
104100
"widget": "choice-multiple-expanded"
105101
},
106102
"name": {
107103
"type": "string",
108-
"title": "The Name",
104+
"title": "Name",
105+
"label": "Name",
109106
"description":
110107
"This key contains the name of the software. It contains the (short) public name of the product, which can be localised in the specific localisation section. It should be the name most people usually refer to the software. In case the software has both an internal 'code' name and a commercial name, use the commercial name.",
111108
"examples": ["Medusa"]

editor/src/app/form/renderFields.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const isRequired = (schema, fieldName) => {
55
if (!schema.required) {
66
return false;
77
}
8-
return (schema.required === true) || schema.required.indexOf(fieldName) !== -1;
8+
return schema.required === true || schema.required.indexOf(fieldName) !== -1;
99
};
1010

1111
const renderFields = (schema, theme, prefix = null, context = {}) => {
@@ -25,6 +25,9 @@ const renderFields = (schema, theme, prefix = null, context = {}) => {
2525
return props.map((item, i) => {
2626
const name = item.prop;
2727
const field = schema.properties[name];
28+
if (schema.isSummary) {
29+
field.isSummary = schema.isSummary;
30+
}
2831

2932
return (
3033
<div className="block__item" key={`obj_item_${i}`}>

editor/src/app/form/widgets/ArrayWidget.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ const renderArrayFields = (
1818
swap
1919
) => {
2020
const prefix = fieldName + ".";
21+
2122
if (count) {
2223
return _times(count, idx => {
24+
let isSummary = false;
25+
if (idx != count - 1) {
26+
isSummary = true;
27+
}
28+
schema.isSummary = isSummary;
2329
return (
2430
<div key={idx}>
2531
<div className="float-right">

editor/src/app/form/widgets/ObjectWidget.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,27 @@ import PropTypes from "prop-types";
33
import renderFields from "../renderFields";
44

55
const Widget = props => {
6+
let isSummary = false;
7+
if (props && props.schema && props.schema.isSummary) {
8+
isSummary = props.schema.isSummary;
9+
}
10+
// console.log(props);
611
return (
7-
<div className="block">
12+
<div className="block" style={{ marginBottom: "10px" }}>
813
{props.showLabel &&
914
props.label && (
10-
<legend className="control-label">
11-
{props.label} {props.schema.required ? "*" : ""}
12-
</legend>
15+
<legend className="control-label">
16+
{props.label} {props.schema.required ? "*" : ""}
17+
</legend>
1318
)}
19+
1420
{renderFields(
1521
props.schema,
1622
props.theme,
1723
props.fieldName && props.fieldName + ".",
1824
props.context
1925
)}
26+
2027
</div>
2128
);
2229
};

editor/src/asset/language_switcher.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.country-switcher {
2+
min-height: 80px;
3+
z-index: 999;
4+
}
5+
16
.language-switcher {
27
display: flex;
38
border-bottom: 1px solid #e8e8e8;

0 commit comments

Comments
 (0)