[ARVADOS-WORKBENCH2] updated: 1.2.0-647-g51d2def

Git user git at public.curoverse.com
Sun Oct 14 12:54:42 EDT 2018


Summary of changes:
 src/components/chips-input/chips-input.tsx         |  2 ++
 src/components/chips/chips.tsx                     | 24 +++++++++++++++-------
 .../run-process-panel/inputs/file-array-input.tsx  |  2 ++
 .../inputs/string-array-input.tsx                  |  2 ++
 4 files changed, 23 insertions(+), 7 deletions(-)

       via  51d2defb6f233bb00ef482f98ca975ae693f0e04 (commit)
      from  f2f7301dab111f2561332c8cc9e7c06df958ea66 (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 51d2defb6f233bb00ef482f98ca975ae693f0e04
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Sun Oct 14 18:54:25 2018 +0200

    Add orderable and deletable flafs to chips
    
    Feature #14232
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/components/chips-input/chips-input.tsx b/src/components/chips-input/chips-input.tsx
index 12932c5..fc5fda0 100644
--- a/src/components/chips-input/chips-input.tsx
+++ b/src/components/chips-input/chips-input.tsx
@@ -15,6 +15,8 @@ interface ChipsInputProps<Value> {
     createNewValue: (value: string) => Value;
     inputComponent?: React.ComponentType<InputProps>;
     inputProps?: InputProps;
+    deletable?: boolean;
+    orderable?: boolean;
 }
 
 type CssRules = 'chips' | 'input' | 'inputContainer';
diff --git a/src/components/chips/chips.tsx b/src/components/chips/chips.tsx
index 8f597de..36cf241 100644
--- a/src/components/chips/chips.tsx
+++ b/src/components/chips/chips.tsx
@@ -5,12 +5,14 @@
 import * as React from 'react';
 import { Chip, Grid, StyleRulesCallback, withStyles } from '@material-ui/core';
 import { DragSource, DragSourceSpec, DragSourceCollector, ConnectDragSource, DropTarget, DropTargetSpec, DropTargetCollector, ConnectDropTarget } from 'react-dnd';
-import { compose } from 'lodash/fp';
+import { compose, noop } from 'lodash/fp';
 import { WithStyles } from '@material-ui/core/styles';
 interface ChipsProps<Value> {
     values: Value[];
     getLabel?: (value: Value) => string;
     filler?: React.ReactNode;
+    deletable?: boolean;
+    orderable?: boolean;
     onChange: (value: Value[]) => void;
 }
 
@@ -75,22 +77,30 @@ export const Chips = withStyles(styles)(
             DragSource(this.type, this.dragSpec, this.dragCollector),
             DropTarget(this.type, this.dropSpec, this.dropCollector),
         )(
-            ({ connectDragSource, connectDropTarget, isOver, value }: DraggableChipProps<Value> & CollectedProps) =>
-                compose(
+            ({ connectDragSource, connectDropTarget, isOver, value }: DraggableChipProps<Value> & CollectedProps) => {
+                const connect = compose(
                     connectDragSource,
                     connectDropTarget,
-                )(
+                );
+
+                const chip =
                     <span>
                         <Chip
                             color={isOver ? 'primary' : 'default'}
-                            onDelete={this.deleteValue(value)}
+                            onDelete={this.props.deletable
+                                ? this.deleteValue(value)
+                                : undefined}
                             label={this.props.getLabel ?
                                 this.props.getLabel(value)
                                 : typeof value === 'object'
                                     ? JSON.stringify(value)
                                     : value} />
-                    </span>
-                )
+                    </span>;
+
+                return this.props.orderable
+                    ? connect(chip)
+                    : chip;
+            }
         );
 
         deleteValue = (value: Value) => () => {
diff --git a/src/views/run-process-panel/inputs/file-array-input.tsx b/src/views/run-process-panel/inputs/file-array-input.tsx
index 39884a6..391cc7f 100644
--- a/src/views/run-process-panel/inputs/file-array-input.tsx
+++ b/src/views/run-process-panel/inputs/file-array-input.tsx
@@ -267,6 +267,8 @@ const FileArrayInputComponent = connect(mapStateToProps)(
                     <div className={classes.chips}>
                         <Typography variant='subheading'>Selected files ({this.state.files.length}):</Typography>
                         <Chips
+                            orderable
+                            deletable
                             values={this.state.files}
                             onChange={this.setFiles}
                             getLabel={(file: CollectionFile) => file.name} />
diff --git a/src/views/run-process-panel/inputs/string-array-input.tsx b/src/views/run-process-panel/inputs/string-array-input.tsx
index dafd946..da03f29 100644
--- a/src/views/run-process-panel/inputs/string-array-input.tsx
+++ b/src/views/run-process-panel/inputs/string-array-input.tsx
@@ -43,6 +43,8 @@ const StringArrayInputComponent = (props: GenericInputProps) =>
 class InputComponent extends React.PureComponent<GenericInputProps>{
     render() {
         return <ChipsInput
+            deletable
+            orderable
             value={this.props.input.value}
             onChange={this.handleChange}
             createNewValue={identity}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list