diff --git a/inputs/complex-list-item.vue b/inputs/complex-list-item.vue index 106ff7941..ca5b32387 100644 --- a/inputs/complex-list-item.vue +++ b/inputs/complex-list-item.vue @@ -9,13 +9,13 @@ border-radius: 2px; box-shadow: $shadow-2dp; padding: 16px 16px 0; - transition: all 200ms $standard-curve; + transition: box-shadow 200ms $standard-curve; &:hover { box-shadow: $shadow-4dp; } - &.is-expanded { + &.is-current { box-shadow: $shadow-8dp; } } @@ -24,6 +24,37 @@ height: 100px; } + .complex-list-item-collapsed { + align-items: center; + cursor: pointer; + display: flex; + flex-flow: row nowrap; + justify-content: flex-start; + padding-bottom: 16px; + } + + .complex-list-item-collapsed-index { + @include type-subheading(); + + color: $text-alt-color; + flex: 0 0 auto; + } + + .complex-list-item-collapsed-title { + @include type-subheading(); + + color: $text-color; + flex: 1 0 auto; + oveflow: hidden; + padding: 0 16px; + text-overflow: ellipsis; + white-space: nowrap; + } + + .complex-list-item-collapsed-caret { + flex: 0 0 auto; + } + .complex-list-item-inner { @include form(); } @@ -70,28 +101,37 @@ @@ -122,9 +162,21 @@ }; }, computed: { + isCollapsible() { + return _.has(this.schema, 'collapse'); + }, + collapsedTitle() { + return _.get(this.data, _.get(this.schema, 'collapse'), 'New Item'); + }, + props() { + return _.get(this, 'schema.props'); + }, isCurrentItem() { return this.currentItem === this.index; }, + isExpanded() { + return this.isCurrentItem || !this.isCollapsible; + }, isFirstItem() { return this.index === 0; }, @@ -132,13 +184,13 @@ return this.index + 1 === this.total; }, fieldNames() { - return _.map(this.schema, (field) => field.prop); // names for all the fields in this item + return _.map(this.props, (field) => field.prop); // names for all the fields in this item }, fields() { return this.data; // data for all the fields in this item }, fieldSchemas() { - return _.reduce(this.schema, (obj, field) => { + return _.reduce(this.props, (obj, field) => { const fieldName = field.prop, fieldSchema = _.omit(field, ['prop']); @@ -148,18 +200,18 @@ }, hasRequiredFields() { // true if any of the fields in the current item have required validation - return _.some(this.schema, (obj) => _.has(obj, `${fieldProp}.validate.required`)); + return _.some(this.props, (obj) => _.has(obj, `${fieldProp}.validate.required`)); } }, methods: { enter(el, done) { this.$nextTick(() => { - velocity(el, 'fadeIn', { duration: 375, complete: done }); + velocity(el, 'fadeIn', { duration: 250, complete: done }); }); }, leave(el, done) { this.$nextTick(() => { - velocity(el, 'fadeOut', { delay: 50, duration: 375, complete: done }); + velocity(el, 'fadeOut', { delay: 50, duration: 250, complete: done }); }); }, addItemAndUnselect(id) { diff --git a/inputs/complex-list.vue b/inputs/complex-list.vue index aa90ea807..8570a7125 100644 --- a/inputs/complex-list.vue +++ b/inputs/complex-list.vue @@ -70,7 +70,7 @@ :total="items.length" :name="name + '.' + index" :data="item" - :schema="args.props" + :schema="args" :key="index" :currentItem="currentItem" :addItem="addItem" @@ -139,9 +139,11 @@ if (direction === 'up') { // up one items.splice(index - 1, 0, item); + this.currentItem = index - 1; } else { // down one items.splice(index + 1, 0, item); + this.currentItem = index + 1; } this.updateFormData(items); // save the data },