[ARVADOS-WORKBENCH2] updated: 1.4.1-58-gec2c868f

Git user git at public.curoverse.com
Mon Nov 11 19:16:56 UTC 2019


Summary of changes:
 src/models/tag.ts                                  |  2 +
 .../collection-panel/collection-panel-action.ts    |  4 +-
 .../property-field-common.tsx                      |  7 ---
 .../property-key-field.tsx                         | 51 +++++++++++++---
 .../property-value-field.tsx                       | 67 ++++++++++++++++------
 .../resource-properties-form.tsx                   |  6 +-
 6 files changed, 103 insertions(+), 34 deletions(-)

       via  ec2c868ff4c0f974ae5f7ca126fe43c02b91d564 (commit)
       via  210cdfd52a1514944b648a694cbe1b2776c1f442 (commit)
       via  c9af1d15f8dd176f335b87c05b10d02e8bbf01f3 (commit)
       via  1830df4301d5e1dda4ac4ffde1eb65df6039d180 (commit)
      from  e92ec7340d9f5354cc05005375a30b34a18bb28d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit ec2c868ff4c0f974ae5f7ca126fe43c02b91d564
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Mon Nov 11 16:12:27 2019 -0300

    15067: When adding/updating a property, use IDs when available.
    
    The tag editor will populate the IDs when the tags belong to a predefined
    vocabulary.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/src/models/tag.ts b/src/models/tag.ts
index 9c229aff..f4e5854a 100644
--- a/src/models/tag.ts
+++ b/src/models/tag.ts
@@ -11,7 +11,9 @@ export interface TagResource extends LinkResource {
 
 export interface TagProperty {
     key: string;
+    keyID?: string;
     value: string;
+    valueID?: string;
 }
 
 export enum TagTailType {
diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts
index 159fb27d..540b8c6a 100644
--- a/src/store/collection-panel/collection-panel-action.ts
+++ b/src/store/collection-panel/collection-panel-action.ts
@@ -49,11 +49,11 @@ export const createCollectionTag = (data: TagProperty) =>
                     uuid, {
                         properties: {
                             ...JSON.parse(JSON.stringify(item.properties)),
-                            [data.key]: data.value
+                            [data.keyID || data.key]: data.valueID || data.value
                         }
                     }
                 );
-                item.properties[data.key] = data.value;
+                item.properties = updatedCollection.properties;
                 dispatch(resourcesActions.SET_RESOURCES([updatedCollection]));
                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Tag has been successfully added.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
                 return updatedCollection;
diff --git a/src/views/collection-panel/collection-tag-form.tsx b/src/views/collection-panel/collection-tag-form.tsx
index 768f4cb8..fd4f0880 100644
--- a/src/views/collection-panel/collection-tag-form.tsx
+++ b/src/views/collection-panel/collection-tag-form.tsx
@@ -12,7 +12,6 @@ const Form = withStyles(({ spacing }) => ({ container: { marginBottom: spacing.u
 export const CollectionTagForm = reduxForm<ResourcePropertiesFormData>({
     form: COLLECTION_TAG_FORM_NAME,
     onSubmit: (data, dispatch) => {
-        console.log('FORM SUBMIT: ', data);
         dispatch<any>(createCollectionTag(data));
         dispatch(reset(COLLECTION_TAG_FORM_NAME));
     }

commit 210cdfd52a1514944b648a694cbe1b2776c1f442
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Mon Nov 11 15:17:51 2019 -0300

    15067: Supports key/value IDs matching when manually typing.
    
    If the user keeps typing instead of selecting what's being suggested, try to
    get the corresponding ID when leaving the input field.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/src/views-components/resource-properties-form/property-key-field.tsx b/src/views-components/resource-properties-form/property-key-field.tsx
index 67e27ce0..5c8c875b 100644
--- a/src/views-components/resource-properties-form/property-key-field.tsx
+++ b/src/views-components/resource-properties-form/property-key-field.tsx
@@ -35,6 +35,7 @@ export const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & V
         suggestions={getSuggestions(props.input.value, vocabulary)}
         onSelect={handleSelect(props.input, props.meta)}
         {...buildProps(props)}
+        onBlur={handleBlur(props.meta, props.input, vocabulary)}
     />;
 
 const getValidation = memoize(
@@ -62,6 +63,23 @@ const getTagsList = ({ tags }: Vocabulary) => {
     return ret;
 };
 
+const getTagKeyID = (tagKeyLabel:string, vocabulary: Vocabulary) =>
+    Object.keys(vocabulary.tags).find(
+        k => vocabulary.tags[k].labels.find(
+            l => l.label === tagKeyLabel) !== undefined) || '';
+
+// Attempts to match a manually typed key label with a key ID, when the user
+// doesn't select the key from the suggestions list.
+const handleBlur = (
+    { dispatch }: WrappedFieldMetaProps,
+    { onBlur, value }: WrappedFieldInputProps,
+    vocabulary: Vocabulary) =>
+    () => {
+        dispatch(change(COLLECTION_TAG_FORM_NAME, PROPERTY_KEY_FIELD_ID, getTagKeyID(value, vocabulary)));
+        onBlur(value);
+    };
+
+// When selecting a property key, save its ID for later usage.
 const handleSelect = (
     { onChange }: WrappedFieldInputProps,
     { dispatch }: WrappedFieldMetaProps) => {
diff --git a/src/views-components/resource-properties-form/property-value-field.tsx b/src/views-components/resource-properties-form/property-value-field.tsx
index 5043bca7..910a095a 100644
--- a/src/views-components/resource-properties-form/property-value-field.tsx
+++ b/src/views-components/resource-properties-form/property-value-field.tsx
@@ -45,6 +45,7 @@ export const PropertyValueInput = ({ vocabulary, propertyKey, ...props }: Wrappe
         suggestions={getSuggestions(props.input.value, propertyKey, vocabulary)}
         onSelect={handleSelect(props.input, props.meta)}
         {...buildProps(props)}
+        onBlur={handleBlur(props.meta, props.input, vocabulary, propertyKey)}
     />;
 
 const getValidation = (props: PropertyValueFieldProps) =>
@@ -77,6 +78,26 @@ const getTagValues = (tagKey: string, vocabulary: Vocabulary) => {
     return ret;
 };
 
+const getTagValueID = (tagKeyID:string, tagValueLabel:string, vocabulary: Vocabulary) =>
+    (tagKeyID && vocabulary.tags[tagKeyID] && vocabulary.tags[tagKeyID].values)
+    ? Object.keys(vocabulary.tags[tagKeyID].values!).find(
+        k => vocabulary.tags[tagKeyID].values![k].labels.find(
+            l => l.label === tagValueLabel) !== undefined) || ''
+    : '';
+
+// Attempts to match a manually typed value label with a value ID, when the user
+// doesn't select the value from the suggestions list.
+const handleBlur = (
+    { dispatch }: WrappedFieldMetaProps,
+    { onBlur, value }: WrappedFieldInputProps,
+    vocabulary: Vocabulary,
+    tagKeyID: string) =>
+    () => {
+        dispatch(change(COLLECTION_TAG_FORM_NAME, PROPERTY_VALUE_FIELD_ID, getTagValueID(tagKeyID, value, vocabulary)));
+        onBlur(value);
+    };
+
+// When selecting a property value, save its ID for later usage.
 const handleSelect = (
     { onChange }: WrappedFieldInputProps,
     { dispatch }: WrappedFieldMetaProps) => {

commit c9af1d15f8dd176f335b87c05b10d02e8bbf01f3
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Mon Nov 11 12:09:16 2019 -0300

    15067: Retrieve property values by its key id.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/src/views-components/resource-properties-form/property-value-field.tsx b/src/views-components/resource-properties-form/property-value-field.tsx
index b93cb514..5043bca7 100644
--- a/src/views-components/resource-properties-form/property-value-field.tsx
+++ b/src/views-components/resource-properties-form/property-value-field.tsx
@@ -7,7 +7,7 @@ import { change, WrappedFieldProps, WrappedFieldMetaProps, WrappedFieldInputProp
 import { compose } from 'redux';
 import { Autocomplete } from '~/components/autocomplete/autocomplete';
 import { Vocabulary } from '~/models/vocabulary';
-import { PROPERTY_KEY_FIELD_NAME } from '~/views-components/resource-properties-form/property-key-field';
+import { PROPERTY_KEY_FIELD_ID } from '~/views-components/resource-properties-form/property-key-field';
 import { VocabularyProp, connectVocabulary, buildProps, PropFieldSuggestion } from '~/views-components/resource-properties-form/property-field-common';
 import { TAG_VALUE_VALIDATION } from '~/validators/validators';
 import { COLLECTION_TAG_FORM_NAME } from '~/store/collection-panel/collection-panel-action';
@@ -23,7 +23,7 @@ export const PROPERTY_VALUE_FIELD_ID = 'valueID';
 
 export const PropertyValueField = compose(
     connectVocabulary,
-    formValues({ propertyKey: PROPERTY_KEY_FIELD_NAME })
+    formValues({ propertyKey: PROPERTY_KEY_FIELD_ID })
 )(
     (props: PropertyValueFieldProps) =>
         <div>
@@ -62,17 +62,12 @@ const getSuggestions = (value: string, tagKey: string, vocabulary: Vocabulary) =
     getTagValues(tagKey, vocabulary).filter(v => v.label.toLowerCase().includes(value.toLowerCase()));
 
 const isStrictTag = (tagKey: string, vocabulary: Vocabulary) => {
-    const tag = vocabulary.tags[getTagID(tagKey, vocabulary)];
+    const tag = vocabulary.tags[tagKey];
     return tag ? tag.strict : false;
 };
 
-const getTagID = (tagKeyLabel:string, vocabulary: Vocabulary) =>
-    Object.keys(vocabulary.tags).find(
-        k => vocabulary.tags[k].labels.find(
-            l => l.label === tagKeyLabel) !== undefined) || tagKeyLabel;
-
 const getTagValues = (tagKey: string, vocabulary: Vocabulary) => {
-    const tag = vocabulary.tags[getTagID(tagKey, vocabulary)];
+    const tag = vocabulary.tags[tagKey];
     const ret = tag && tag.values
         ? Object.keys(tag.values).map(
             tagValueID => tag.values![tagValueID].labels

commit 1830df4301d5e1dda4ac4ffde1eb65df6039d180
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Mon Nov 11 10:23:17 2019 -0300

    15067: Assign key/value ids to hidden field so they're available on submit.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/src/views-components/resource-properties-form/property-field-common.tsx b/src/views-components/resource-properties-form/property-field-common.tsx
index b431905d..a0f5800f 100644
--- a/src/views-components/resource-properties-form/property-field-common.tsx
+++ b/src/views-components/resource-properties-form/property-field-common.tsx
@@ -32,19 +32,12 @@ export const handleBlur = ({ onBlur, value }: WrappedFieldInputProps) =>
     () =>
         onBlur(value);
 
-export const handleSelect = ({ onChange }: WrappedFieldInputProps) => {
-    return (item:PropFieldSuggestion) => {
-        onChange(item.label);
-    };
-};
-
 export const buildProps = ({ input, meta }: WrappedFieldProps) => {
     return {
         value: input.value,
         onChange: input.onChange,
         onBlur: handleBlur(input),
         items: ITEMS_PLACEHOLDER,
-        onSelect: handleSelect(input),
         renderSuggestion: (item:PropFieldSuggestion) => item.label,
         error: hasError(meta),
         helperText: getErrorMsg(meta),
diff --git a/src/views-components/resource-properties-form/property-key-field.tsx b/src/views-components/resource-properties-form/property-key-field.tsx
index e040d32f..67e27ce0 100644
--- a/src/views-components/resource-properties-form/property-key-field.tsx
+++ b/src/views-components/resource-properties-form/property-key-field.tsx
@@ -3,27 +3,37 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { WrappedFieldProps, Field } from 'redux-form';
+import { change, WrappedFieldProps, WrappedFieldMetaProps, WrappedFieldInputProps, Field } from 'redux-form';
 import { memoize } from 'lodash';
 import { Autocomplete } from '~/components/autocomplete/autocomplete';
 import { Vocabulary } from '~/models/vocabulary';
-import { connectVocabulary, VocabularyProp, buildProps } from '~/views-components/resource-properties-form/property-field-common';
+import { connectVocabulary, VocabularyProp, buildProps, PropFieldSuggestion } from '~/views-components/resource-properties-form/property-field-common';
 import { TAG_KEY_VALIDATION } from '~/validators/validators';
+import { COLLECTION_TAG_FORM_NAME } from '~/store/collection-panel/collection-panel-action';
 
 export const PROPERTY_KEY_FIELD_NAME = 'key';
+export const PROPERTY_KEY_FIELD_ID = 'keyID';
 
 export const PropertyKeyField = connectVocabulary(
     ({ vocabulary }: VocabularyProp) =>
-        <Field
-            name={PROPERTY_KEY_FIELD_NAME}
-            component={PropertyKeyInput}
-            vocabulary={vocabulary}
-            validate={getValidation(vocabulary)} />);
+        <div>
+            <Field
+                name={PROPERTY_KEY_FIELD_NAME}
+                component={PropertyKeyInput}
+                vocabulary={vocabulary}
+                validate={getValidation(vocabulary)} />
+            <Field
+                name={PROPERTY_KEY_FIELD_ID}
+                type='hidden'
+                component='input' />
+        </div>
+);
 
 export const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) =>
     <Autocomplete
         label='Key'
         suggestions={getSuggestions(props.input.value, vocabulary)}
+        onSelect={handleSelect(props.input, props.meta)}
         {...buildProps(props)}
     />;
 
@@ -51,3 +61,12 @@ const getTagsList = ({ tags }: Vocabulary) => {
         : [];
     return ret;
 };
+
+const handleSelect = (
+    { onChange }: WrappedFieldInputProps,
+    { dispatch }: WrappedFieldMetaProps) => {
+        return (item:PropFieldSuggestion) => {
+            onChange(item.label);
+            dispatch(change(COLLECTION_TAG_FORM_NAME, PROPERTY_KEY_FIELD_ID, item.id));
+    };
+};
diff --git a/src/views-components/resource-properties-form/property-value-field.tsx b/src/views-components/resource-properties-form/property-value-field.tsx
index 5e104566..b93cb514 100644
--- a/src/views-components/resource-properties-form/property-value-field.tsx
+++ b/src/views-components/resource-properties-form/property-value-field.tsx
@@ -3,13 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { WrappedFieldProps, Field, formValues } from 'redux-form';
+import { change, WrappedFieldProps, WrappedFieldMetaProps, WrappedFieldInputProps, Field, formValues } from 'redux-form';
 import { compose } from 'redux';
 import { Autocomplete } from '~/components/autocomplete/autocomplete';
 import { Vocabulary } from '~/models/vocabulary';
 import { PROPERTY_KEY_FIELD_NAME } from '~/views-components/resource-properties-form/property-key-field';
-import { VocabularyProp, connectVocabulary, buildProps } from '~/views-components/resource-properties-form/property-field-common';
+import { VocabularyProp, connectVocabulary, buildProps, PropFieldSuggestion } from '~/views-components/resource-properties-form/property-field-common';
 import { TAG_VALUE_VALIDATION } from '~/validators/validators';
+import { COLLECTION_TAG_FORM_NAME } from '~/store/collection-panel/collection-panel-action';
 
 interface PropertyKeyProp {
     propertyKey: string;
@@ -18,22 +19,31 @@ interface PropertyKeyProp {
 export type PropertyValueFieldProps = VocabularyProp & PropertyKeyProp;
 
 export const PROPERTY_VALUE_FIELD_NAME = 'value';
+export const PROPERTY_VALUE_FIELD_ID = 'valueID';
 
 export const PropertyValueField = compose(
     connectVocabulary,
     formValues({ propertyKey: PROPERTY_KEY_FIELD_NAME })
 )(
     (props: PropertyValueFieldProps) =>
-        <Field
-            name={PROPERTY_VALUE_FIELD_NAME}
-            component={PropertyValueInput}
-            validate={getValidation(props)}
-            {...props} />);
+        <div>
+            <Field
+                name={PROPERTY_VALUE_FIELD_NAME}
+                component={PropertyValueInput}
+                validate={getValidation(props)}
+                {...props} />
+            <Field
+                name={PROPERTY_VALUE_FIELD_ID}
+                type='hidden'
+                component='input' />
+        </div>
+);
 
 export const PropertyValueInput = ({ vocabulary, propertyKey, ...props }: WrappedFieldProps & PropertyValueFieldProps) =>
     <Autocomplete
         label='Value'
         suggestions={getSuggestions(props.input.value, propertyKey, vocabulary)}
+        onSelect={handleSelect(props.input, props.meta)}
         {...buildProps(props)}
     />;
 
@@ -71,3 +81,12 @@ const getTagValues = (tagKey: string, vocabulary: Vocabulary) => {
         : [];
     return ret;
 };
+
+const handleSelect = (
+    { onChange }: WrappedFieldInputProps,
+    { dispatch }: WrappedFieldMetaProps) => {
+        return (item:PropFieldSuggestion) => {
+            onChange(item.label);
+            dispatch(change(COLLECTION_TAG_FORM_NAME, PROPERTY_VALUE_FIELD_ID, item.id));
+    };
+};
diff --git a/src/views-components/resource-properties-form/resource-properties-form.tsx b/src/views-components/resource-properties-form/resource-properties-form.tsx
index 6c2e025a..db40e4a7 100644
--- a/src/views-components/resource-properties-form/resource-properties-form.tsx
+++ b/src/views-components/resource-properties-form/resource-properties-form.tsx
@@ -5,14 +5,16 @@
 import * as React from 'react';
 import { InjectedFormProps } from 'redux-form';
 import { Grid, withStyles, WithStyles } from '@material-ui/core';
-import { PropertyKeyField, PROPERTY_KEY_FIELD_NAME } from './property-key-field';
-import { PropertyValueField, PROPERTY_VALUE_FIELD_NAME } from './property-value-field';
+import { PropertyKeyField, PROPERTY_KEY_FIELD_NAME, PROPERTY_KEY_FIELD_ID } from './property-key-field';
+import { PropertyValueField, PROPERTY_VALUE_FIELD_NAME, PROPERTY_VALUE_FIELD_ID } from './property-value-field';
 import { ProgressButton } from '~/components/progress-button/progress-button';
 import { GridClassKey } from '@material-ui/core/Grid';
 
 export interface ResourcePropertiesFormData {
     [PROPERTY_KEY_FIELD_NAME]: string;
+    [PROPERTY_KEY_FIELD_ID]: string;
     [PROPERTY_VALUE_FIELD_NAME]: string;
+    [PROPERTY_VALUE_FIELD_ID]: string;
 }
 
 export type ResourcePropertiesFormProps = InjectedFormProps<ResourcePropertiesFormData> & WithStyles<GridClassKey>;
diff --git a/src/views/collection-panel/collection-tag-form.tsx b/src/views/collection-panel/collection-tag-form.tsx
index fd4f0880..768f4cb8 100644
--- a/src/views/collection-panel/collection-tag-form.tsx
+++ b/src/views/collection-panel/collection-tag-form.tsx
@@ -12,6 +12,7 @@ const Form = withStyles(({ spacing }) => ({ container: { marginBottom: spacing.u
 export const CollectionTagForm = reduxForm<ResourcePropertiesFormData>({
     form: COLLECTION_TAG_FORM_NAME,
     onSubmit: (data, dispatch) => {
+        console.log('FORM SUBMIT: ', data);
         dispatch<any>(createCollectionTag(data));
         dispatch(reset(COLLECTION_TAG_FORM_NAME));
     }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list