formset component
This commit is contained in:
parent
b82f8f4527
commit
07983d7378
|
@ -155,7 +155,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var core
|
|||
\***************************************************************************************************************************************************************************************/
|
||||
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _AList_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AList.vue */ \"./src/components/AList.vue\");\n/* harmony import */ var _ARow_vue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ARow.vue */ \"./src/components/ARow.vue\");\n\n\nconst Component = {\n extends: _AList_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n components: {\n ARow: _ARow_vue__WEBPACK_IMPORTED_MODULE_1__[\"default\"]\n },\n emits: ['cell', 'colmove'],\n props: {\n ..._AList_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].props,\n //! Ordered list of columns, as objects with:\n //! - name: item attribute value\n //! - label: display label\n //! - help: help text\n //! - hidden: if true, field is hidden\n columns: Array,\n //! If True, columns are orderable\n columnsOrderable: Boolean\n },\n data() {\n return {\n ...super.data,\n // TODO: add observer\n columns_: [...this.columns],\n extraItem: new this.set.model()\n };\n },\n computed: {\n columnNames() {\n return this.columns_.map(c => c.name);\n },\n columnLabels() {\n return this.columns_.map(c => c.label);\n },\n rowSlots() {\n return Object.keys(this.$slots).filter(x => x.startsWith('row-')).map(x => [x, x.slice(4)]);\n }\n },\n methods: {\n /**\n * Move column using provided event object (as `{from, to}`)\n */\n moveColumn(event) {\n const {\n from,\n to\n } = event;\n const value = this.columns_[from];\n this.columns_.splice(from, 1);\n this.columns_.splice(to, 0, value);\n this.$emit('colmove', event);\n },\n /**\n * React on 'cell' event, re-emitting it with additional values:\n * - `set`: data set\n * - `row`: row index\n *\n * @param {Number} row: row index\n * @param {} data: cell's event data\n */\n onCellEvent(row, event) {\n if (event.name == 'focus') this.focus(event.data, event.cell);\n this.$emit('cell', {\n ...event,\n row,\n set: this.set\n });\n },\n /**\n * Return row component at provided index\n */\n getRow(row) {\n const els = this.$el.querySelectorAll('tr');\n for (var el of els) if (el.__row && row == Number(el.dataset.row)) return el.__row;\n },\n /**\n * Focus on a cell\n */\n focus(row, col, from = null) {\n if (from) row += from.row;\n row = this.getRow(row);\n row && row.focus(col, from);\n }\n }\n};\nComponent.props.itemTag.default = 'tr';\nComponent.props.listTag.default = 'tbody';\n/* harmony default export */ __webpack_exports__[\"default\"] = (Component);\n\n//# sourceURL=webpack://aircox-assets/./src/components/ARows.vue?./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use%5B0%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B0%5D.use%5B0%5D");
|
||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _AList_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AList.vue */ \"./src/components/AList.vue\");\n/* harmony import */ var _ARow_vue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ARow.vue */ \"./src/components/ARow.vue\");\n\n\nconst Component = {\n extends: _AList_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n components: {\n ARow: _ARow_vue__WEBPACK_IMPORTED_MODULE_1__[\"default\"]\n },\n emits: ['cell', 'colmove'],\n props: {\n ..._AList_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].props,\n //! Ordered list of columns, as objects with:\n //! - name: item attribute value\n //! - label: display label\n //! - help: help text\n //! - hidden: if true, field is hidden\n columns: Array,\n //! If True, columns are orderable\n columnsOrderable: Boolean\n },\n data() {\n return {\n ...super.data,\n // TODO: add observer\n columns_: [...this.columns],\n extraItem: new this.set.model()\n };\n },\n computed: {\n columnNames() {\n return this.columns_.map(c => c.name);\n },\n columnLabels() {\n return this.columns_.reduce((labels, c) => ({\n ...labels,\n [c.name]: c.label\n }), {});\n },\n rowSlots() {\n return Object.keys(this.$slots).filter(x => x.startsWith('row-')).map(x => [x, x.slice(4)]);\n }\n },\n methods: {\n /**\n * Move column using provided event object (as `{from, to}`)\n */\n moveColumn(event) {\n const {\n from,\n to\n } = event;\n const value = this.columns_[from];\n this.columns_.splice(from, 1);\n this.columns_.splice(to, 0, value);\n this.$emit('colmove', event);\n },\n /**\n * React on 'cell' event, re-emitting it with additional values:\n * - `set`: data set\n * - `row`: row index\n *\n * @param {Number} row: row index\n * @param {} data: cell's event data\n */\n onCellEvent(row, event) {\n if (event.name == 'focus') this.focus(event.data, event.cell);\n this.$emit('cell', {\n ...event,\n row,\n set: this.set\n });\n },\n /**\n * Return row component at provided index\n */\n getRow(row) {\n const els = this.$el.querySelectorAll('tr');\n for (var el of els) if (el.__row && row == Number(el.dataset.row)) return el.__row;\n },\n /**\n * Focus on a cell\n */\n focus(row, col, from = null) {\n if (from) row += from.row;\n row = this.getRow(row);\n row && row.focus(col, from);\n }\n }\n};\nComponent.props.itemTag.default = 'tr';\nComponent.props.listTag.default = 'tbody';\n/* harmony default export */ __webpack_exports__[\"default\"] = (Component);\n\n//# sourceURL=webpack://aircox-assets/./src/components/ARows.vue?./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use%5B0%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B0%5D.use%5B0%5D");
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
|
|
@ -72,7 +72,10 @@ const Component = {
|
|||
|
||||
computed: {
|
||||
columnNames() { return this.columns_.map(c => c.name) },
|
||||
columnLabels() { return this.columns_.map(c => c.label) },
|
||||
columnLabels() { return this.columns_.reduce(
|
||||
(labels, c) => ({...labels, [c.name]: c.label}),
|
||||
{}
|
||||
)},
|
||||
rowSlots() {
|
||||
return Object.keys(this.$slots).filter(x => x.startsWith('row-'))
|
||||
.map(x => [x, x.slice(4)])
|
||||
|
|
Loading…
Reference in New Issue
Block a user