From e0af92ee81ff1d83a60c84b3b561d1997ca70dc3 Mon Sep 17 00:00:00 2001 From: hevp Date: Wed, 29 Apr 2020 11:29:54 +0200 Subject: [PATCH 1/3] Support units in metadata schemas and display them --- webui/src/components/editrecord.jsx | 12 ++++++++++-- webui/src/components/record.jsx | 4 +++- webui/src/components/schema.jsx | 27 ++++++++++++--------------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/webui/src/components/editrecord.jsx b/webui/src/components/editrecord.jsx index 92720a09b1..41c14d4620 100644 --- a/webui/src/components/editrecord.jsx +++ b/webui/src/components/editrecord.jsx @@ -384,8 +384,16 @@ const EditRecord = React.createClass({
{!title ? false : }
diff --git a/webui/src/components/record.jsx b/webui/src/components/record.jsx index ebcecc0002..2cf076cea8 100644 --- a/webui/src/components/record.jsx +++ b/webui/src/components/record.jsx @@ -327,7 +327,9 @@ const Record = React.createClass({ }
- {inner}
+ {inner} + {schema.get('unit') ? { schema.get('unit') } : false } +
); }, diff --git a/webui/src/components/schema.jsx b/webui/src/components/schema.jsx index 09cbc13446..62267c4425 100644 --- a/webui/src/components/schema.jsx +++ b/webui/src/components/schema.jsx @@ -67,23 +67,20 @@ export const Schema = React.createClass({ inner = {inner} } - const leftcolumn = !id ? false : -
-

- {title} - - {title?" :: ":""} - {id} - {schema.get('isRequired') ? " (required)":false} - -

-

{schema.get('description')}

-
; - const rightcolumnsize = leftcolumn ? "col-sm-6" : "col-sm-12"; return (
  • - {leftcolumn} -
    {inner}
    +
    +

    + {title} {schema.get('unit') ? ' [' + schema.get('unit') + ']' : false } + + {title ? " :: " : ""} + {id} + {schema.get('isRequired') ? " (required)" : false} + +

    +

    {schema.get('description')}

    +
    +
    {inner}
  • ); }, From 88bfaa858d4b2b8245d0f6cd5e1ea5613b2a603f Mon Sep 17 00:00:00 2001 From: hevp Date: Wed, 29 Apr 2020 11:31:02 +0200 Subject: [PATCH 2/3] Support units in metadata schemas and display them --- b2share/modules/schemas/validate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/b2share/modules/schemas/validate.py b/b2share/modules/schemas/validate.py index 5cde8499f9..000dda1b66 100644 --- a/b2share/modules/schemas/validate.py +++ b/b2share/modules/schemas/validate.py @@ -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"] }, From 6547d868fe92fd658193d85eb5b3f3c3068dfd7a Mon Sep 17 00:00:00 2001 From: hevp Date: Thu, 30 Apr 2020 17:46:42 +0200 Subject: [PATCH 3/3] Update schema field unit layout --- webui/app/css/app.css | 12 ++++++++++++ webui/src/components/editrecord.jsx | 6 +++--- webui/src/components/schema.jsx | 7 ++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/webui/app/css/app.css b/webui/app/css/app.css index f3fd71d2cf..507f75cf7b 100644 --- a/webui/app/css/app.css +++ b/webui/app/css/app.css @@ -782,10 +782,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 */ diff --git a/webui/src/components/editrecord.jsx b/webui/src/components/editrecord.jsx index 41c14d4620..9415f8bb21 100644 --- a/webui/src/components/editrecord.jsx +++ b/webui/src/components/editrecord.jsx @@ -386,13 +386,13 @@ const EditRecord = React.createClass({ } diff --git a/webui/src/components/schema.jsx b/webui/src/components/schema.jsx index 62267c4425..4dc86d3254 100644 --- a/webui/src/components/schema.jsx +++ b/webui/src/components/schema.jsx @@ -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'); @@ -70,8 +70,9 @@ export const Schema = React.createClass({ return (
  • -

    - {title} {schema.get('unit') ? ' [' + schema.get('unit') + ']' : false } +

    + {title} + {schema.get('unit') ? ' (' + schema.get('unit') + ')' : false } {title ? " :: " : ""} {id}