File: /home/nepi/public_html/public/admin/js/chunk-4b51bd42.b133c4e5.js.map
{"version":3,"sources":["webpack:///./src/interfaces/translation/input.vue?25dd","webpack:///./src/interfaces/translation/input.vue?53d0","webpack:///src/interfaces/translation/input.vue","webpack:///./src/interfaces/translation/input.vue?dfef","webpack:///./src/interfaces/translation/input.vue","webpack:///./node_modules/@directus/extension-toolkit/mixins/interface.js"],"names":["render","_vm","this","_h","$createElement","_c","_self","staticClass","attrs","options","languages","model","value","callback","$$v","currentLanguage","expression","loading","initialValues","key","relation","collection_many","collection","translatedFields","currentLanguageValues","existing","translationsCollectionPrimaryKeyField","on","saveLanguage","_v","_s","$t","staticRenderFns","component","module","exports","props","id","type","String","required","name","default","length","Number","readonly","Boolean","primaryKey","Object","newItem","fields","values","width","val","includes"],"mappings":"kHAAA,yBAAujB,EAAG,G,yCCA1jB,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAmBC,EAAGJ,EAAIK,MAAMD,IAAIF,EAAG,OAAQF,EAAqB,kBAAEI,EAAG,UAAU,CAACA,EAAG,WAAW,CAACE,YAAY,kBAAkBC,MAAM,CAAC,QAAUP,EAAIQ,QAAQC,UAAU,KAAO,aAAaC,MAAM,CAACC,MAAOX,EAAmB,gBAAEY,SAAS,SAAUC,GAAMb,EAAIc,gBAAgBD,GAAKE,WAAW,qBAAqBX,EAAG,OAAuB,IAAhBJ,EAAIgB,SAA2C,OAAtBhB,EAAIiB,cAAwBb,EAAG,MAAM,CAACE,YAAY,QAAQ,CAACF,EAAG,SAAS,CAACc,IAAIlB,EAAIc,gBAAgBP,MAAM,CAAC,aAAa,GAAG,WAAaP,EAAImB,SAASC,gBAAgBC,WAAW,OAASrB,EAAIsB,iBAAiB,OAAStB,EAAIuB,sBAAsB,cAAcvB,EAAIwB,UAAYxB,EAAIwB,SAASxB,EAAIyB,wCAAwCC,GAAG,CAAC,cAAc1B,EAAI2B,iBAAiB,GAAGvB,EAAG,cAAc,GAAGA,EA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NL,KAAM,CAACC,OAAQK,QACfF,QAAS,MAGXG,SAAU,CACRP,KAAMQ,QACNJ,SAAS,GAGXpB,WAAY,CACVgB,KAAMC,OACNG,QAAS,MAGXK,WAAY,CACVT,KAAM,CAACM,OAAQL,QACfG,QAAS,MAGXF,SAAU,CACRF,KAAMQ,QACNJ,SAAS,GAGXjC,QAAS,CACP6B,KAAMU,OACNN,QAAS,KAAM,KAGjBO,QAAS,CACPX,KAAMQ,QACNJ,SAAS,GAIXtB,SAAU,CACRkB,KAAMU,OACNN,QAAS,MAGXQ,OAAQ,CACNZ,KAAMU,OACNN,QAAS,MAIXS,OAAQ,CACNb,KAAMU,OACNN,QAAS,MAEXU,MAAO,CACLd,KAAMC,OACNG,QAAS,KACT,UAAUW,GACR,MAAO,CACL,OACA,YACA,aACA,OACA,QACAC,SAASD,Q","file":"js/chunk-4b51bd42.b133c4e5.js","sourcesContent":["import mod from \"-!../../../node_modules/mini-css-extract-plugin/dist/loader.js??ref--8-oneOf-1-0!../../../node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-2!../../../node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./input.vue?vue&type=style&index=0&id=403d2817&lang=scss&scoped=true&\"; export default mod; export * from \"-!../../../node_modules/mini-css-extract-plugin/dist/loader.js??ref--8-oneOf-1-0!../../../node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-2!../../../node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./input.vue?vue&type=style&index=0&id=403d2817&lang=scss&scoped=true&\"","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.relationshipSetup)?_c('v-sheet',[_c('v-select',{staticClass:\"language-picker\",attrs:{\"options\":_vm.options.languages,\"icon\":\"translate\"},model:{value:(_vm.currentLanguage),callback:function ($$v) {_vm.currentLanguage=$$v},expression:\"currentLanguage\"}}),_c('hr'),(_vm.loading === false && _vm.initialValues !== null)?_c('div',{staticClass:\"body\"},[_c('v-form',{key:_vm.currentLanguage,attrs:{\"full-width\":\"\",\"collection\":_vm.relation.collection_many.collection,\"fields\":_vm.translatedFields,\"values\":_vm.currentLanguageValues,\"primary-key\":_vm.existing && _vm.existing[_vm.translationsCollectionPrimaryKeyField]},on:{\"stage-value\":_vm.saveLanguage}})],1):_c('v-spinner')],1):_c('v-notice',{attrs:{\"color\":\"warning\",\"icon\":\"warning\"}},[_vm._v(\" \"+_vm._s(_vm.$t('relationship_not_setup'))+\" \")])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","<template>\n\t<v-sheet v-if=\"relationshipSetup\">\n\t\t<v-select\n\t\t\tv-model=\"currentLanguage\"\n\t\t\tclass=\"language-picker\"\n\t\t\t:options=\"options.languages\"\n\t\t\ticon=\"translate\"\n\t\t/>\n\n\t\t<hr />\n\n\t\t<div v-if=\"loading === false && initialValues !== null\" class=\"body\">\n\t\t\t<v-form\n\t\t\t\tfull-width\n\t\t\t\t:key=\"currentLanguage\"\n\t\t\t\t:collection=\"relation.collection_many.collection\"\n\t\t\t\t:fields=\"translatedFields\"\n\t\t\t\t:values=\"currentLanguageValues\"\n\t\t\t\t:primary-key=\"existing && existing[translationsCollectionPrimaryKeyField]\"\n\t\t\t\t@stage-value=\"saveLanguage\"\n\t\t\t/>\n\t\t</div>\n\n\t\t<v-spinner v-else />\n\t</v-sheet>\n\n\t<v-notice v-else color=\"warning\" icon=\"warning\">\n\t\t{{ $t('relationship_not_setup') }}\n\t</v-notice>\n</template>\n\n<script>\nimport mixin from '@directus/extension-toolkit/mixins/interface';\nimport { mapValues, clone, find, merge } from 'lodash';\n\nexport default {\n\tmixins: [mixin],\n\tdata() {\n\t\treturn {\n\t\t\tcurrentLanguage: Object.keys(this.options.languages)[0],\n\t\t\tloading: false,\n\t\t\tinitialValues: null,\n\t\t\trelationalChanges: []\n\t\t};\n\t},\n\tcomputed: {\n\t\ttranslatedFields() {\n\t\t\tif (this.relationshipSetup === false) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn mapValues(this.relation.collection_many.fields, field => {\n\t\t\t\tfield = clone(field); // remove vue reactivity\n\n\t\t\t\t// Prevent updating the recursive relational key\n\t\t\t\tif (field.field === this.relation.field_many.field) {\n\t\t\t\t\tfield.readonly = true;\n\t\t\t\t}\n\n\t\t\t\treturn field;\n\t\t\t});\n\t\t},\n\t\tdefaults() {\n\t\t\treturn mapValues(clone(this.translatedFields), f => f.default_value);\n\t\t},\n\t\texisting() {\n\t\t\treturn find(this.initialValues, {\n\t\t\t\t[this.options.languageField]: this.currentLanguage\n\t\t\t});\n\t\t},\n\t\ttranslationsCollectionPrimaryKeyField() {\n\t\t\treturn Object.values(this.relation.collection_many.fields).find(\n\t\t\t\tfield => field.primary_key === true\n\t\t\t).field;\n\t\t},\n\t\tcurrentLanguageValues() {\n\t\t\tconst existingChanges = find(this.relationalChanges, {\n\t\t\t\t[this.options.languageField]: this.currentLanguage\n\t\t\t});\n\n\t\t\treturn merge({}, this.existing || this.defaults, existingChanges);\n\t\t},\n\t\trelationshipSetup() {\n\t\t\treturn !!this.relation?.collection_many;\n\t\t},\n\t\tcurrentPrimaryKey() {\n\t\t\tconst { field } = find(this.fields, { primary_key: true });\n\t\t\treturn this.values[field];\n\t\t}\n\t},\n\twatch: {\n\t\trelationalChanges: {\n\t\t\tdeep: true,\n\t\t\thandler(value) {\n\t\t\t\tif (value) {\n\t\t\t\t\tthis.emitValue(value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tcreated() {\n\t\tthis.fetchInitial();\n\t},\n\tmethods: {\n\t\tsaveLanguage({ field, value }) {\n\t\t\tconst existingChanges = find(this.relationalChanges, {\n\t\t\t\t[this.options.languageField]: this.currentLanguage\n\t\t\t});\n\n\t\t\tif (existingChanges) {\n\t\t\t\tthis.relationalChanges = this.relationalChanges.map(update => {\n\t\t\t\t\tif (update[this.options.languageField] === this.currentLanguage) {\n\t\t\t\t\t\treturn merge({}, update, { [field]: value });\n\t\t\t\t\t}\n\n\t\t\t\t\treturn update;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst update = {\n\t\t\t\t\t[field]: value,\n\t\t\t\t\t[this.options.languageField]: this.currentLanguage\n\t\t\t\t};\n\n\t\t\t\tif (this.existing) {\n\t\t\t\t\tconst primaryKeyField = find(this.translatedFields, { primary_key: true })\n\t\t\t\t\t\t.field;\n\t\t\t\t\tconst relatedPrimaryKey = this.existing[primaryKeyField];\n\t\t\t\t\tupdate[primaryKeyField] = relatedPrimaryKey;\n\t\t\t\t}\n\n\t\t\t\tthis.relationalChanges = [...this.relationalChanges, update];\n\t\t\t}\n\t\t},\n\t\temitValue(value) {\n\t\t\tif (this.initialValues.length == 0) {\n\t\t\t\tthis.$emit('input', value);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// This is the key in the nested related object that holds the parent item again\n\t\t\tconst languageField = this.options.languageField;\n\n\t\t\tconst newValue = this.initialValues\n\t\t\t\t.map(before => {\n\t\t\t\t\tconst languageKey = before[languageField];\n\n\t\t\t\t\t// Check if the current item was saved before\n\t\t\t\t\tconst after = value.find(i => i[languageField] === languageKey);\n\n\t\t\t\t\tif (after) {\n\t\t\t\t\t\treturn merge({}, before, after);\n\t\t\t\t\t}\n\t\t\t\t\treturn before;\n\t\t\t\t})\n\t\t\t\t.filter(i => i);\n\n\t\t\t// if there is new langauge added, then need to push to the results\n\t\t\tvalue.forEach(after => {\n\t\t\t\tconst languageKey = after[languageField];\n\t\t\t\tconst before = newValue.find(i => i[languageField] === languageKey);\n\t\t\t\tif (!before) {\n\t\t\t\t\tnewValue.push(after);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthis.$emit('input', newValue);\n\t\t},\n\t\tasync fetchInitial() {\n\t\t\tif (this.relationshipSetup === false) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/*if (this.newItem) {\n\t\t\t\tthis.initialValues = [];\n\t\t\t\treturn;\n\t\t\t}*/\n\n\t\t\tif (this.values && this.values[this.relation.field_one.field]) {\n\t\t\t\tthis.initialValues = this.values[this.relation.field_one.field];\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.loading = true;\n\t\t\tconst { collection } = this.relation.collection_many;\n\t\t\tconst { field } = this.relation.field_many;\n\n\t\t\tconst { data } = await this.$api.getItems(collection, {\n\t\t\t\tfilter: {\n\t\t\t\t\t[field]: {\n\t\t\t\t\t\teq: this.currentPrimaryKey\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthis.initialValues = data;\n\t\t\tthis.loading = false;\n\t\t}\n\t}\n};\n</script>\n\n<style lang=\"scss\" scoped>\n.language-picker {\n\tmargin-bottom: 24px;\n}\n\nhr {\n\tborder: none;\n\tborder-bottom: 2px solid var(--input-border-color);\n\tborder-radius: 1px;\n\tmargin-bottom: 24px;\n}\n\n.body {\n\t--form-vertical-gap: 24px;\n\t--form-horizontal-gap: 12px;\n\t--type-label-size: 15px;\n\t--input-height: 44px;\n\t--input-font-size: 14px;\n\t--input-label-margin: 4px;\n\t--input-background-color-alt: var(--input-background-color);\n}\n</style>\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./input.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./input.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./input.vue?vue&type=template&id=403d2817&scoped=true&\"\nimport script from \"./input.vue?vue&type=script&lang=js&\"\nexport * from \"./input.vue?vue&type=script&lang=js&\"\nimport style0 from \"./input.vue?vue&type=style&index=0&id=403d2817&lang=scss&scoped=true&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"403d2817\",\n null\n \n)\n\nexport default component.exports","module.exports = {\n props: {\n // Unique id for this interface. Should be added to the lower level \n // HTML input element if applicable. This ID will be used in the label's\n // `for` attribute\n id: {\n type: String,\n required: true\n },\n // Name of the field\n name: {\n type: String,\n required: true\n },\n // The current value. This can either be the default value, the saved database\n // value or the current state after the user made an edit\n value: {\n type: null,\n default: null\n },\n // Type of the field, eg `string`, `hash`, or `array`\n type: {\n type: String,\n required: true\n },\n // Max length\n length: {\n type: [String, Number],\n default: null\n },\n // If the field is readonly or not\n readonly: {\n type: Boolean,\n default: false\n },\n // Name of the collection\n collection: {\n type: String,\n default: null\n },\n // Primary key of the item you're editing in this context\n primaryKey: {\n type: [Number, String],\n default: null\n },\n // If the field is required or not\n required: {\n type: Boolean,\n default: false\n },\n // Field options. A json object based on the interface's meta.json file\n options: {\n type: Object,\n default: () => ({})\n },\n // If the item that's currently being edited is new\n newItem: {\n type: Boolean,\n default: false\n },\n // The relation of the current field. Will contain information on the related\n // collection and field(s)\n relation: {\n type: Object,\n default: null\n },\n // The other fields in the current edit page\n fields: {\n type: Object,\n default: null\n },\n // The values of the other fields on the edit page. Can be used for things like\n // automatically generating a slug based on another field\n values: {\n type: Object,\n default: null\n },\n width: {\n type: String,\n default: null,\n validator(val) {\n return [\n 'half',\n 'half-left',\n 'half-right',\n 'full',\n 'fill'\n ].includes(val);\n }\n }\n }\n};\n"],"sourceRoot":""}