From 4af84cf92f633c6e1453f7ace54c081d4e78a7d0 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Sun, 9 Sep 2018 17:49:34 +0300 Subject: [PATCH] Move fix to backend --- medusa/__main__.py | 38 ++++++++++++++++++ .../slim/src/components/select-list.vue | 16 ++++---- .../slim/test/specs/select-list.spec.js | 30 -------------- .../specs/snapshots/select-list.spec.js.md | 6 --- .../specs/snapshots/select-list.spec.js.snap | Bin 480 -> 430 bytes themes/dark/assets/js/vendors.js | 2 +- themes/light/assets/js/vendors.js | 2 +- 7 files changed, 49 insertions(+), 45 deletions(-) diff --git a/medusa/__main__.py b/medusa/__main__.py index 66f92934c3..50c0006880 100755 --- a/medusa/__main__.py +++ b/medusa/__main__.py @@ -95,6 +95,34 @@ logger = logging.getLogger(__name__) +def fix_incorrect_list_values(data): + """ + @TODO: Remove this in a future version. + + Due to a bug introduced in v0.2.9, the value might be a string representing a Python dict. + See: https://github.com/pymedusa/Medusa/issues/5155 + + Example: `"{u'id': 0, u'value': u'!sync'}"` to `"!sync"` + """ + import ast + + result = [] + for item in data: + if not item: + continue + if not (item.startswith('{') and item.endswith('}')): + # Simple value, don't do anything to it + result.append(item) + continue + try: + # Get the value: `{u'id': 0, u'value': u'!sync'}` => `!sync` + result.append(ast.literal_eval(item)['value']) + except (SyntaxError, KeyError): + pass + + return result + + class Application(object): """Main application module.""" @@ -604,7 +632,11 @@ def initialize(self, console_logging=True): app.RANDOMIZE_PROVIDERS = bool(check_setting_int(app.CFG, 'General', 'randomize_providers', 0)) app.ALLOW_HIGH_PRIORITY = bool(check_setting_int(app.CFG, 'General', 'allow_high_priority', 1)) app.SKIP_REMOVED_FILES = bool(check_setting_int(app.CFG, 'General', 'skip_removed_files', 0)) + app.ALLOWED_EXTENSIONS = check_setting_list(app.CFG, 'General', 'allowed_extensions', app.ALLOWED_EXTENSIONS) + # @TODO: Remove this in a future version. + app.ALLOWED_EXTENSIONS = fix_incorrect_list_values(app.ALLOWED_EXTENSIONS) + app.USENET_RETENTION = check_setting_int(app.CFG, 'General', 'usenet_retention', 500) app.CACHE_TRIMMING = bool(check_setting_int(app.CFG, 'General', 'cache_trimming', 0)) app.MAX_CACHE_AGE = check_setting_int(app.CFG, 'General', 'max_cache_age', 30) @@ -646,7 +678,11 @@ def initialize(self, console_logging=True): app.MOVE_ASSOCIATED_FILES = bool(check_setting_int(app.CFG, 'General', 'move_associated_files', 0)) app.POSTPONE_IF_SYNC_FILES = bool(check_setting_int(app.CFG, 'General', 'postpone_if_sync_files', 1)) app.POSTPONE_IF_NO_SUBS = bool(check_setting_int(app.CFG, 'General', 'postpone_if_no_subs', 0)) + app.SYNC_FILES = check_setting_list(app.CFG, 'General', 'sync_files', app.SYNC_FILES) + # @TODO: Remove this in a future version. + app.SYNC_FILES = fix_incorrect_list_values(app.SYNC_FILES) + app.NFO_RENAME = bool(check_setting_int(app.CFG, 'General', 'nfo_rename', 1)) app.CREATE_MISSING_SHOW_DIRS = bool(check_setting_int(app.CFG, 'General', 'create_missing_show_dirs', 0)) app.ADD_SHOWS_WO_DIR = bool(check_setting_int(app.CFG, 'General', 'add_shows_wo_dir', 0)) @@ -919,6 +955,8 @@ def initialize(self, console_logging=True): app.NO_RESTART = bool(check_setting_int(app.CFG, 'General', 'no_restart', 0)) app.EXTRA_SCRIPTS = [x.strip() for x in check_setting_list(app.CFG, 'General', 'extra_scripts')] + # @TODO: Remove this in a future version. + app.EXTRA_SCRIPTS = fix_incorrect_list_values(app.EXTRA_SCRIPTS) app.USE_LISTVIEW = bool(check_setting_int(app.CFG, 'General', 'use_listview', 0)) diff --git a/themes-default/slim/src/components/select-list.vue b/themes-default/slim/src/components/select-list.vue index bebbae3cfd..36ef78d486 100644 --- a/themes-default/slim/src/components/select-list.vue +++ b/themes-default/slim/src/components/select-list.vue @@ -63,6 +63,14 @@ export default { }; }, created() { + /* + These are needed in order to test the component, + but they break the component in the application: + + this.editItems = this.sanitize(this.listItems); + this.csv = this.editItems.map(item => item.value).join(', '); + */ + /** * ListItems property might receive values originating from the API, * that are sometimes not available when rendering. @@ -72,7 +80,7 @@ export default { unwatchProp(); this.editItems = this.sanitize(this.listItems); - this.csv = this.editItems.map(x => x.value).join(', '); + this.csv = this.editItems.map(item => item.value).join(', '); }); }, methods: { @@ -110,12 +118,6 @@ export default { return values.map((value, index) => { if (typeof (value) === 'string') { - // Due to a bug introduced in v0.2.9, the value might be a string representing a Python dict. - if (value.startsWith('{') && value.endsWith('}')) { - // Get the value: `{u'id': 0, u'value': u'!sync'}` => `!sync` - value = value.match(/u?'value': u?'(.+)'/)[1].replace(`\\'`, `'`); // eslint-disable-line quotes - } - return { id: index, value diff --git a/themes-default/slim/test/specs/select-list.spec.js b/themes-default/slim/test/specs/select-list.spec.js index 87db680f14..f40489127a 100644 --- a/themes-default/slim/test/specs/select-list.spec.js +++ b/themes-default/slim/test/specs/select-list.spec.js @@ -58,33 +58,3 @@ test.failing('renders with values', t => { t.snapshot(wrapper.html()); }); - -test.failing('renders with Python dict values (v0.2.9 bug)', t => { - const { localVue, store } = t.context; - const wrapper = mount(SelectList, { - localVue, - store, - propsData: { - listItems: [ - `{u'id': 0, u'value': u'!sync'}`, // eslint-disable-line quotes - `{u'id': 1, u'value': u'lftp-pget-status'}` // eslint-disable-line quotes - ] - } - }); - - const expectedItems = [ - '!sync', - 'lftp-pget-status' - ]; - - const inputWrapperArray = wrapper.findAll('li input[type="text"]'); - - t.is(inputWrapperArray.length, expectedItems.length); - - inputWrapperArray.wrappers.forEach((inputWrapper, index) => { - const { element } = inputWrapper; - t.is(element.value, expectedItems[index]); - }); - - t.snapshot(wrapper.html()); -}); diff --git a/themes-default/slim/test/specs/snapshots/select-list.spec.js.md b/themes-default/slim/test/specs/snapshots/select-list.spec.js.md index 95360d4e22..948413a96e 100644 --- a/themes-default/slim/test/specs/snapshots/select-list.spec.js.md +++ b/themes-default/slim/test/specs/snapshots/select-list.spec.js.md @@ -10,12 +10,6 @@ Generated by [AVA](https://ava.li). '
' -## renders with Python dict values (v0.2.9 bug) - -> Snapshot 1 - - '
' - ## renders with values > Snapshot 1 diff --git a/themes-default/slim/test/specs/snapshots/select-list.spec.js.snap b/themes-default/slim/test/specs/snapshots/select-list.spec.js.snap index 54024700d80adf1eba85df5851c70fac4e57bf18..b7bd7d7fbbdd4df4a609bb886b775707c305c607 100644 GIT binary patch literal 430 zcmV;f0a5-zRzVm+}h=sjY+HGzp$->^_VuxwRPX3!jPDfmLTFimPtV!zY$0v zNeb)!X(lP`KocoLjDbUu%3}dx5=9&=YHm28fG$@lT7QgO6fzm>l%TEpx+B9Ro_sNb zErT|1R*{V$RgGz0F=k8>M*d8+0Ap>Fq&nwVKvQ2knuI;_K`S0&Cs6`T-RDApgBkGx zjmB}0aZIq4n20$dWD*5KWV^T@Yf?OW=mOv#Ca}d*MH2|H)X$}BIc#R-1y*7IK=*3X zvK|UCCNfVPtx`Kurs8_ed+#u}+)u7t5t*_1xxBPCEBPx^m%*+RjFK+?=$IL%Ec7g& YdNuj~n|yVt{pnKs2K7wxANB?S08U%Pi2wiq literal 480 zcmV<60U!QBRzV1K@jb67X`!1g>oW68W9ZcZa+W_%+Vh5|8Z5XCJs&mQuU@@3U0aN?3fpD}>t7ewYL$hnY7Nut zfEDAHzn!W>za!QxH%t6{&HMPsiq^XVF W5B`2DpB(L19qqq~v?zJ&3IG7P(&BUg diff --git a/themes/dark/assets/js/vendors.js b/themes/dark/assets/js/vendors.js index 3d7d0fe691..460e5f9a5f 100644 --- a/themes/dark/assets/js/vendors.js +++ b/themes/dark/assets/js/vendors.js @@ -747,7 +747,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* WEBPACK VAR INJECTION */(f /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n name: 'select-list',\n props: {\n listItems: {\n type: Array,\n default: function _default() {\n return [];\n },\n required: true\n },\n unique: {\n type: Boolean,\n default: true,\n required: false\n },\n csvEnabled: {\n type: Boolean,\n default: false,\n required: false\n }\n },\n data: function data() {\n return {\n editItems: [],\n newItem: '',\n indexCounter: 0,\n csv: '',\n csvMode: this.csvEnabled\n };\n },\n created: function created() {\n var _this = this;\n\n /**\n * ListItems property might receive values originating from the API,\n * that are sometimes not available when rendering.\n * @TODO: This is not ideal! Maybe we can remove this in the future.\n */\n var unwatchProp = this.$watch('listItems', function () {\n unwatchProp();\n _this.editItems = _this.sanitize(_this.listItems);\n _this.csv = _this.editItems.map(function (x) {\n return x.value;\n }).join(', ');\n });\n },\n methods: {\n addItem: function addItem(item) {\n if (this.unique && this.editItems.find(function (i) {\n return i.value === item;\n })) {\n return;\n }\n\n this.editItems.push({\n id: this.indexCounter,\n value: item\n });\n this.indexCounter += 1;\n },\n addNewItem: function addNewItem() {\n if (this.newItem === '') {\n return;\n }\n\n this.addItem(this.newItem);\n this.newItem = '';\n },\n deleteItem: function deleteItem(item) {\n this.editItems = this.editItems.filter(function (e) {\n return e !== item;\n });\n this.$refs.newItemInput.focus();\n },\n removeEmpty: function removeEmpty(item) {\n return item.value === '' ? this.deleteItem(item) : false;\n },\n\n /**\n * Initially an array of strings is passed, which we'd like to translate to an array of object.\n * Where the index has been added.\n * @param {string[]} values - Array of strings.\n * @returns {Object[]} - An array of objects with the index and value.\n */\n sanitize: function sanitize(values) {\n if (!values) {\n return [];\n }\n\n return values.map(function (value, index) {\n if (typeof value === 'string') {\n // Due to a bug introduced in v0.2.9, the value might be a string representing a Python dict.\n if (value.startsWith('{') && value.endsWith('}')) {\n // Get the value: `{u'id': 0, u'value': u'!sync'}` => `!sync`\n value = value.match(/u?'value': u?'(.+)'/)[1].replace(\"\\\\'\", \"'\"); // eslint-disable-line quotes\n }\n\n return {\n id: index,\n value: value\n };\n }\n\n return value;\n });\n },\n\n /**\n * Depending on which option is selected, sync the data to the other.\n * Sync from editItems to a csv (comma separated) field.\n * Or from csv to editItems.\n */\n syncValues: function syncValues() {\n var _this2 = this;\n\n if (this.csvMode) {\n this.editItems = [];\n this.csv.split(',').forEach(function (value) {\n // Omit empty strings\n if (value.trim()) {\n _this2.addItem(value.trim());\n }\n });\n } else {\n this.csv = this.editItems.map(function (item) {\n return item.value;\n }).join(', ');\n }\n },\n\n /**\n * When switching between a list of inputs and a csv input\n * whe're making sure that 1. the data is updated in editItems (which is the source of truth)\n * and this.csv, which keeps track of the csv.\n */\n switchFields: function switchFields() {\n this.syncValues();\n this.csvMode = !this.csvMode;\n }\n },\n watch: {\n editItems: {\n handler: function handler() {\n this.$emit('change', this.editItems);\n },\n deep: true\n },\n csv: function csv() {\n this.syncValues();\n }\n }\n});\n\n//# sourceURL=webpack:///./src/components/select-list.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); +eval("__webpack_require__.r(__webpack_exports__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n name: 'select-list',\n props: {\n listItems: {\n type: Array,\n default: function _default() {\n return [];\n },\n required: true\n },\n unique: {\n type: Boolean,\n default: true,\n required: false\n },\n csvEnabled: {\n type: Boolean,\n default: false,\n required: false\n }\n },\n data: function data() {\n return {\n editItems: [],\n newItem: '',\n indexCounter: 0,\n csv: '',\n csvMode: this.csvEnabled\n };\n },\n created: function created() {\n var _this = this;\n\n /*\n These are needed in order to test the component,\n but they break the component in the application:\n this.editItems = this.sanitize(this.listItems);\n this.csv = this.editItems.map(item => item.value).join(', ');\n */\n\n /**\n * ListItems property might receive values originating from the API,\n * that are sometimes not available when rendering.\n * @TODO: This is not ideal! Maybe we can remove this in the future.\n */\n var unwatchProp = this.$watch('listItems', function () {\n unwatchProp();\n _this.editItems = _this.sanitize(_this.listItems);\n _this.csv = _this.editItems.map(function (item) {\n return item.value;\n }).join(', ');\n });\n },\n methods: {\n addItem: function addItem(item) {\n if (this.unique && this.editItems.find(function (i) {\n return i.value === item;\n })) {\n return;\n }\n\n this.editItems.push({\n id: this.indexCounter,\n value: item\n });\n this.indexCounter += 1;\n },\n addNewItem: function addNewItem() {\n if (this.newItem === '') {\n return;\n }\n\n this.addItem(this.newItem);\n this.newItem = '';\n },\n deleteItem: function deleteItem(item) {\n this.editItems = this.editItems.filter(function (e) {\n return e !== item;\n });\n this.$refs.newItemInput.focus();\n },\n removeEmpty: function removeEmpty(item) {\n return item.value === '' ? this.deleteItem(item) : false;\n },\n\n /**\n * Initially an array of strings is passed, which we'd like to translate to an array of object.\n * Where the index has been added.\n * @param {string[]} values - Array of strings.\n * @returns {Object[]} - An array of objects with the index and value.\n */\n sanitize: function sanitize(values) {\n if (!values) {\n return [];\n }\n\n return values.map(function (value, index) {\n if (typeof value === 'string') {\n return {\n id: index,\n value: value\n };\n }\n\n return value;\n });\n },\n\n /**\n * Depending on which option is selected, sync the data to the other.\n * Sync from editItems to a csv (comma separated) field.\n * Or from csv to editItems.\n */\n syncValues: function syncValues() {\n var _this2 = this;\n\n if (this.csvMode) {\n this.editItems = [];\n this.csv.split(',').forEach(function (value) {\n // Omit empty strings\n if (value.trim()) {\n _this2.addItem(value.trim());\n }\n });\n } else {\n this.csv = this.editItems.map(function (item) {\n return item.value;\n }).join(', ');\n }\n },\n\n /**\n * When switching between a list of inputs and a csv input\n * whe're making sure that 1. the data is updated in editItems (which is the source of truth)\n * and this.csv, which keeps track of the csv.\n */\n switchFields: function switchFields() {\n this.syncValues();\n this.csvMode = !this.csvMode;\n }\n },\n watch: {\n editItems: {\n handler: function handler() {\n this.$emit('change', this.editItems);\n },\n deep: true\n },\n csv: function csv() {\n this.syncValues();\n }\n }\n});\n\n//# sourceURL=webpack:///./src/components/select-list.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), diff --git a/themes/light/assets/js/vendors.js b/themes/light/assets/js/vendors.js index 3d7d0fe691..460e5f9a5f 100644 --- a/themes/light/assets/js/vendors.js +++ b/themes/light/assets/js/vendors.js @@ -747,7 +747,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* WEBPACK VAR INJECTION */(f /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n name: 'select-list',\n props: {\n listItems: {\n type: Array,\n default: function _default() {\n return [];\n },\n required: true\n },\n unique: {\n type: Boolean,\n default: true,\n required: false\n },\n csvEnabled: {\n type: Boolean,\n default: false,\n required: false\n }\n },\n data: function data() {\n return {\n editItems: [],\n newItem: '',\n indexCounter: 0,\n csv: '',\n csvMode: this.csvEnabled\n };\n },\n created: function created() {\n var _this = this;\n\n /**\n * ListItems property might receive values originating from the API,\n * that are sometimes not available when rendering.\n * @TODO: This is not ideal! Maybe we can remove this in the future.\n */\n var unwatchProp = this.$watch('listItems', function () {\n unwatchProp();\n _this.editItems = _this.sanitize(_this.listItems);\n _this.csv = _this.editItems.map(function (x) {\n return x.value;\n }).join(', ');\n });\n },\n methods: {\n addItem: function addItem(item) {\n if (this.unique && this.editItems.find(function (i) {\n return i.value === item;\n })) {\n return;\n }\n\n this.editItems.push({\n id: this.indexCounter,\n value: item\n });\n this.indexCounter += 1;\n },\n addNewItem: function addNewItem() {\n if (this.newItem === '') {\n return;\n }\n\n this.addItem(this.newItem);\n this.newItem = '';\n },\n deleteItem: function deleteItem(item) {\n this.editItems = this.editItems.filter(function (e) {\n return e !== item;\n });\n this.$refs.newItemInput.focus();\n },\n removeEmpty: function removeEmpty(item) {\n return item.value === '' ? this.deleteItem(item) : false;\n },\n\n /**\n * Initially an array of strings is passed, which we'd like to translate to an array of object.\n * Where the index has been added.\n * @param {string[]} values - Array of strings.\n * @returns {Object[]} - An array of objects with the index and value.\n */\n sanitize: function sanitize(values) {\n if (!values) {\n return [];\n }\n\n return values.map(function (value, index) {\n if (typeof value === 'string') {\n // Due to a bug introduced in v0.2.9, the value might be a string representing a Python dict.\n if (value.startsWith('{') && value.endsWith('}')) {\n // Get the value: `{u'id': 0, u'value': u'!sync'}` => `!sync`\n value = value.match(/u?'value': u?'(.+)'/)[1].replace(\"\\\\'\", \"'\"); // eslint-disable-line quotes\n }\n\n return {\n id: index,\n value: value\n };\n }\n\n return value;\n });\n },\n\n /**\n * Depending on which option is selected, sync the data to the other.\n * Sync from editItems to a csv (comma separated) field.\n * Or from csv to editItems.\n */\n syncValues: function syncValues() {\n var _this2 = this;\n\n if (this.csvMode) {\n this.editItems = [];\n this.csv.split(',').forEach(function (value) {\n // Omit empty strings\n if (value.trim()) {\n _this2.addItem(value.trim());\n }\n });\n } else {\n this.csv = this.editItems.map(function (item) {\n return item.value;\n }).join(', ');\n }\n },\n\n /**\n * When switching between a list of inputs and a csv input\n * whe're making sure that 1. the data is updated in editItems (which is the source of truth)\n * and this.csv, which keeps track of the csv.\n */\n switchFields: function switchFields() {\n this.syncValues();\n this.csvMode = !this.csvMode;\n }\n },\n watch: {\n editItems: {\n handler: function handler() {\n this.$emit('change', this.editItems);\n },\n deep: true\n },\n csv: function csv() {\n this.syncValues();\n }\n }\n});\n\n//# sourceURL=webpack:///./src/components/select-list.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); +eval("__webpack_require__.r(__webpack_exports__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n name: 'select-list',\n props: {\n listItems: {\n type: Array,\n default: function _default() {\n return [];\n },\n required: true\n },\n unique: {\n type: Boolean,\n default: true,\n required: false\n },\n csvEnabled: {\n type: Boolean,\n default: false,\n required: false\n }\n },\n data: function data() {\n return {\n editItems: [],\n newItem: '',\n indexCounter: 0,\n csv: '',\n csvMode: this.csvEnabled\n };\n },\n created: function created() {\n var _this = this;\n\n /*\n These are needed in order to test the component,\n but they break the component in the application:\n this.editItems = this.sanitize(this.listItems);\n this.csv = this.editItems.map(item => item.value).join(', ');\n */\n\n /**\n * ListItems property might receive values originating from the API,\n * that are sometimes not available when rendering.\n * @TODO: This is not ideal! Maybe we can remove this in the future.\n */\n var unwatchProp = this.$watch('listItems', function () {\n unwatchProp();\n _this.editItems = _this.sanitize(_this.listItems);\n _this.csv = _this.editItems.map(function (item) {\n return item.value;\n }).join(', ');\n });\n },\n methods: {\n addItem: function addItem(item) {\n if (this.unique && this.editItems.find(function (i) {\n return i.value === item;\n })) {\n return;\n }\n\n this.editItems.push({\n id: this.indexCounter,\n value: item\n });\n this.indexCounter += 1;\n },\n addNewItem: function addNewItem() {\n if (this.newItem === '') {\n return;\n }\n\n this.addItem(this.newItem);\n this.newItem = '';\n },\n deleteItem: function deleteItem(item) {\n this.editItems = this.editItems.filter(function (e) {\n return e !== item;\n });\n this.$refs.newItemInput.focus();\n },\n removeEmpty: function removeEmpty(item) {\n return item.value === '' ? this.deleteItem(item) : false;\n },\n\n /**\n * Initially an array of strings is passed, which we'd like to translate to an array of object.\n * Where the index has been added.\n * @param {string[]} values - Array of strings.\n * @returns {Object[]} - An array of objects with the index and value.\n */\n sanitize: function sanitize(values) {\n if (!values) {\n return [];\n }\n\n return values.map(function (value, index) {\n if (typeof value === 'string') {\n return {\n id: index,\n value: value\n };\n }\n\n return value;\n });\n },\n\n /**\n * Depending on which option is selected, sync the data to the other.\n * Sync from editItems to a csv (comma separated) field.\n * Or from csv to editItems.\n */\n syncValues: function syncValues() {\n var _this2 = this;\n\n if (this.csvMode) {\n this.editItems = [];\n this.csv.split(',').forEach(function (value) {\n // Omit empty strings\n if (value.trim()) {\n _this2.addItem(value.trim());\n }\n });\n } else {\n this.csv = this.editItems.map(function (item) {\n return item.value;\n }).join(', ');\n }\n },\n\n /**\n * When switching between a list of inputs and a csv input\n * whe're making sure that 1. the data is updated in editItems (which is the source of truth)\n * and this.csv, which keeps track of the csv.\n */\n switchFields: function switchFields() {\n this.syncValues();\n this.csvMode = !this.csvMode;\n }\n },\n watch: {\n editItems: {\n handler: function handler() {\n this.$emit('change', this.editItems);\n },\n deep: true\n },\n csv: function csv() {\n this.syncValues();\n }\n }\n});\n\n//# sourceURL=webpack:///./src/components/select-list.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }),