ColumnWrapper.vue
2 years ago
CxVuiCollapseMini.vue
2 years ago
CxVuiDate.vue
2 years ago
CxVuiFSelect.vue
2 years ago
CxVuiPopup.vue
2 years ago
CxVuiSelect.vue
2 years ago
CxVuiTabs.vue
2 years ago
CxVuiTabsPanel.vue
2 years ago
Delimiter.vue
2 years ago
DetailsTable.vue
2 years ago
DetailsTableRow.vue
2 years ago
DetailsTableRowValue.vue
2 years ago
ExternalLink.vue
2 years ago
ListComponents.vue
2 years ago
PrintButton.vue
2 years ago
RowWrapper.vue
2 years ago
Tooltip.vue
2 years ago
DetailsTableRowValue.vue
164 lines
| 1 | <template> |
| 2 | <ul :class="rootClasses" v-show="! this.withIndent"> |
| 3 | <li |
| 4 | v-for="( itemValue, itemName ) in value" |
| 5 | :key="itemName" |
| 6 | class="jfb-recursive-details-row" |
| 7 | v-if="isHiddenLevel( itemName )" |
| 8 | > |
| 9 | <template v-if="isSkipLevel( itemName )"> |
| 10 | <DetailsTableRowValue |
| 11 | :value="itemValue" |
| 12 | :columns="getChildren( itemName )" |
| 13 | /> |
| 14 | </template> |
| 15 | <template v-else> |
| 16 | <span :class="itemClasses( true )" v-if="isObject( itemValue )"> |
| 17 | <span |
| 18 | class="jfb-recursive-details-item--heading" |
| 19 | @click="toggleNext( itemName )" |
| 20 | > |
| 21 | {{ getItemLabel( itemName ) }} |
| 22 | <span :class="arrowClasses( itemName )"></span> |
| 23 | </span> |
| 24 | <span class="jfb-recursive-details-item--content"> |
| 25 | <transition name="fade"> |
| 26 | <DetailsTableRowValue |
| 27 | :value="itemValue" |
| 28 | :with-indent="true" |
| 29 | v-show="isShow( itemName )" |
| 30 | :columns="getChildren( itemName )" |
| 31 | /> |
| 32 | </transition> |
| 33 | </span> |
| 34 | </span> |
| 35 | <span :class="itemClasses( false )" v-else> |
| 36 | <span class="jfb-recursive-details-item--heading">{{ getItemLabel( itemName ) }}</span> |
| 37 | <span class="jfb-recursive-details-item--content">{{ itemValue }}</span> |
| 38 | </span> |
| 39 | </template> |
| 40 | </li> |
| 41 | </ul> |
| 42 | </template> |
| 43 | |
| 44 | <script> |
| 45 | export default { |
| 46 | name: 'DetailsTableRowValue', |
| 47 | props: { |
| 48 | value: Object, |
| 49 | withIndent: { |
| 50 | type: Boolean, |
| 51 | default: false, |
| 52 | }, |
| 53 | columns: { |
| 54 | type: Object, |
| 55 | default() { |
| 56 | return {}; |
| 57 | }, |
| 58 | }, |
| 59 | }, |
| 60 | data() { |
| 61 | return { |
| 62 | showNext: {}, |
| 63 | }; |
| 64 | }, |
| 65 | computed: { |
| 66 | rootClasses() { |
| 67 | return { |
| 68 | 'jfb-recursive-details': true, |
| 69 | 'jfb-recursive-details--indent': this.withIndent, |
| 70 | }; |
| 71 | }, |
| 72 | }, |
| 73 | methods: { |
| 74 | getChildren( columnName ) { |
| 75 | return ( |
| 76 | this.columns[ columnName ]?.children || [] |
| 77 | ); |
| 78 | }, |
| 79 | getItemLabel( columnName ) { |
| 80 | return this.columns[ columnName ] ? this.columns[ columnName ].label : columnName; |
| 81 | }, |
| 82 | isObject( itemValue ) { |
| 83 | return 'object' === typeof itemValue; |
| 84 | }, |
| 85 | toggleNext( name ) { |
| 86 | const prev = this.showNext[ name ] || false; |
| 87 | |
| 88 | this.$set( this.showNext, name, ! prev ); |
| 89 | }, |
| 90 | isShow( name ) { |
| 91 | return 'undefined' === this.showNext[ name ] ? true : this.showNext[ name ]; |
| 92 | }, |
| 93 | itemClasses( isObject = true ) { |
| 94 | return { |
| 95 | 'jfb-recursive-details-item': true, |
| 96 | 'jfb-recursive-details-item-with-children': isObject, |
| 97 | 'jfb-recursive-details-item-without-children': ! isObject, |
| 98 | }; |
| 99 | }, |
| 100 | arrowClasses( columnName ) { |
| 101 | return { |
| 102 | dashicons: true, |
| 103 | 'dashicons-arrow-down-alt2': ! this.isShow( columnName ), |
| 104 | 'dashicons-arrow-up-alt2': this.isShow( columnName ), |
| 105 | }; |
| 106 | }, |
| 107 | isSkipLevel( columnName ) { |
| 108 | return this.columns[ columnName ]?.skip_level; |
| 109 | }, |
| 110 | isHiddenLevel( columnName ) { |
| 111 | return ( ! this.columns[ columnName ]?.hide ); |
| 112 | }, |
| 113 | }, |
| 114 | }; |
| 115 | </script> |
| 116 | |
| 117 | <style lang="scss" scoped> |
| 118 | .fade-enter-active, .fade-leave-active { |
| 119 | transition: opacity .5s; |
| 120 | } |
| 121 | |
| 122 | .fade-enter, .fade-leave-to /* .fade-leave-active до версии 2.1.8 */ |
| 123 | { |
| 124 | opacity: 0; |
| 125 | } |
| 126 | |
| 127 | .jfb-recursive-details { |
| 128 | &:not( &--indent ) { |
| 129 | margin-top: unset; |
| 130 | } |
| 131 | |
| 132 | &--indent { |
| 133 | margin-left: 1.5em; |
| 134 | margin-top: 0.5em; |
| 135 | } |
| 136 | |
| 137 | &-row { |
| 138 | &:not( :last-child ) { |
| 139 | margin-bottom: 0.5em; |
| 140 | padding-bottom: 0.5em; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | |
| 145 | &-item { |
| 146 | &--content { |
| 147 | border-bottom: 1px solid #ccc; |
| 148 | } |
| 149 | |
| 150 | &-without-children > &--heading::after { |
| 151 | content: ':'; |
| 152 | } |
| 153 | |
| 154 | &-with-children > &--heading { |
| 155 | cursor: pointer; |
| 156 | |
| 157 | &:hover { |
| 158 | color: #2271b1; |
| 159 | border-bottom-color: #2271b1; |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | </style> |