From 58e57ed7076fe3ef6f2f63377b529efe3f09ee2d 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 2a024b6b18..c9ffcfb556 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 f6543cd673..9f912afc39 100644 --- a/webui/src/components/record.jsx +++ b/webui/src/components/record.jsx @@ -445,7 +445,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 c5f83376eff20c9c4e42f33c53acbb9559fe0932 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 73edbec1abb51afd2311e6a33d0af47e55876273 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 8cc7b8ab3c..e52be1c1c0 100644 --- a/webui/app/css/app.css +++ b/webui/app/css/app.css @@ -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 */ diff --git a/webui/src/components/editrecord.jsx b/webui/src/components/editrecord.jsx index c9ffcfb556..f6f6de4136 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}