Unverified Commit 6c771cf5 authored by Nicolas Widart's avatar Nicolas Widart Committed by GitHub

Merge pull request #644 from mikemand/feature/media-deeply-nested-objects

Allow deeply nested objects to have media
parents 9c5b5d71 773f160a
...@@ -10,5 +10,6 @@ yarn-error.log ...@@ -10,5 +10,6 @@ yarn-error.log
.env .env
composer.lock composer.lock
package-lock.json package-lock.json
yarn.lock
.phpunit.result.cache .phpunit.result.cache
.php_cs.cache .php_cs.cache
import t from 'typy';
export default { export default {
methods: { methods: {
selectMultipleFile(event, model) { selectMultipleFile(event, model) {
if (typeof this[model].medias_multi === 'undefined') { const entity = t(this, model).safeObject;
this.$set(model, 'medias_multi', {});
if (typeof entity.medias_multi === 'undefined') {
this.$set(entity, 'medias_multi', {});
} }
if (typeof this[model].medias_multi[event.zone] === 'undefined') { if (typeof entity.medias_multi[event.zone] === 'undefined') {
this.$set(this[model].medias_multi, event.zone, { files: [], orders: '' }); this.$set(entity.medias_multi, event.zone, { files: [], orders: '' });
} }
if (event.id !== null && event.id !== undefined) { if (event.id !== null && event.id !== undefined) {
const medias = new Set(this[model].medias_multi[event.zone].files); const medias = new Set(entity.medias_multi[event.zone].files);
medias.add(event.id); medias.add(event.id);
this.$set(this[model].medias_multi[event.zone], 'files', [...medias]); this.$set(entity.medias_multi[event.zone], 'files', [...medias]);
} }
}, },
unselectFile(event, model) { unselectFile(event, model) {
const entity = t(this, model).safeObject;
if (event.id !== null && event.id !== undefined) { if (event.id !== null && event.id !== undefined) {
const medias = new Set(this[model].medias_multi[event.zone].files); const medias = new Set(entity.medias_multi[event.zone].files);
medias.delete(event.id); medias.delete(event.id);
this.$set(this[model].medias_multi[event.zone], 'files', [...medias]); this.$set(entity.medias_multi[event.zone], 'files', [...medias]);
} }
if (this[model].medias_multi[event.zone].files.length === 0) { if (entity.medias_multi[event.zone].files.length === 0) {
this.$delete(this[model].medias_multi, event.zone); this.$delete(entity.medias_multi, event.zone);
} }
}, },
}, },
......
import t from 'typy';
export default { export default {
methods: { methods: {
selectSingleFile(event, model) { selectSingleFile(event, model) {
if (typeof this[model].medias_single === 'undefined') { const entity = t(this, model).safeObject;
this.$set(this[model], 'medias_single', {});
if (typeof entity.medias_single === 'undefined') {
this.$set(entity, 'medias_single', {});
} }
if (typeof this[model].medias_single[event.zone] === 'undefined') { if (typeof entity.medias_single[event.zone] === 'undefined') {
this.$set(this[model].medias_single, event.zone, null); this.$set(entity.medias_single, event.zone, null);
} }
if (event.id !== null && event.id !== undefined) { if (event.id !== null && event.id !== undefined) {
this.$set(this[model].medias_single, event.zone, event.id); this.$set(entity.medias_single, event.zone, event.id);
} else { } else {
this.$delete(this[model].medias_single, event.zone); this.$delete(entity.medias_single, event.zone);
} }
}, },
}, },
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment