Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema unit #1784

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions b2share/modules/schemas/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
# the properties which are defined must have this structure
"title": {"type": "string"},
"description": {"type": "string"},
"unit": {"type": "string"},
"type": {
"enum": ["boolean", "integer", "number", "string", "array"]
},
Expand Down
12 changes: 12 additions & 0 deletions webui/app/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,22 @@ a.navbar-brand {
color: #333;
}

.schema-field {
font-weight: bold;
}

.schema-field span:nth-child(2) {
color: grey;
}

.required.property {
color: #F45D00;
}

.required.property span:nth-child(2) {
color: #FF9D63;
}

/*****************************************************************************/
/* help and about pages */

Expand Down
12 changes: 10 additions & 2 deletions webui/src/components/editrecord.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,16 @@ const EditRecord = React.createClass({
<div key={id} style={{marginBottom:'0.5em'}} title={schema.get('description')}>
{!title ? false :
<label htmlFor={id} className="col-sm-3 control-label" style={{fontWeight:'bold'}}>
<span style={{float:'right', color:isError?'red':'black'}}>
{title} {schema.get('isRequired') ? "*":""}
<span style={{float:'right'}}>
<span style={{color:isError?'red':'black'}}>
{title}
</span>
<span>
{schema.get('unit') ? <span style={{color: 'grey'}}>&nbsp;{'(' + schema.get('unit') + ')'}</span> : false }
</span>
<span>
&nbsp;{schema.get('isRequired') ? "*" : ""}
</span>
</span>
</label> }
<div className={title ? "col-sm-9":"col-sm-12"} style={arrstyle} onFocus={onfocus} onBlur={onblur}>
Expand Down
4 changes: 3 additions & 1 deletion webui/src/components/record.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ const Record = React.createClass({
}
<div className={
(title ? "col-sm-8" : "col-sm-12") + " " + (type === 'object' ? "metadata-object" : "metadata")}>
{inner} </div>
{inner}
{schema.get('unit') ? <span style={{color: 'grey'}}> { schema.get('unit') } </span> : false }
</div>
</li>
);
},
Expand Down
30 changes: 14 additions & 16 deletions webui/src/components/schema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Schema = React.createClass({
mixins: [React.addons.PureRenderMixin],

renderSchema([id, schema]) {
const requiredClass = schema.get('isRequired') ? "required property":"";
const requiredClass = schema.get('isRequired') ? "required property" : "";

const type = schema.get('type');
const title = schema.get('title');
Expand Down Expand Up @@ -67,23 +67,21 @@ export const Schema = React.createClass({
inner = <span className="mono-style">{inner}</span>
}

const leftcolumn = !id ? false :
<div className="col-sm-6">
<p className={requiredClass}>
<span className="bold">{title}</span>
<span className="mono-style">
{title?" :: ":""}
{id}
{schema.get('isRequired') ? " (required)":false}
</span>
</p>
<p> {schema.get('description')} </p>
</div>;
const rightcolumnsize = leftcolumn ? "col-sm-6" : "col-sm-12";
return (
<li key={id} className="row field-general">
{leftcolumn}
<div className={rightcolumnsize}> {inner} </div>
<div className="col-sm-6">
<p className={"schema-field " + requiredClass}>
<span>{title}</span>
<span>{schema.get('unit') ? ' (' + schema.get('unit') + ')' : false }</span>
<span className="mono-style">
{title ? " :: " : ""}
{id}
{schema.get('isRequired') ? " (required)" : false}
</span>
</p>
<p> {schema.get('description')} </p>
</div>
<div className="col-sm-6"> {inner} </div>
</li>
);
},
Expand Down