Skip to content

Commit

Permalink
fix multi-edit modal
Browse files Browse the repository at this point in the history
Signed-off-by: Vinzenz Rosenkranz <[email protected]>
  • Loading branch information
v1r0x committed Oct 16, 2023
1 parent 27d1994 commit 8b4d66b
Showing 1 changed file with 32 additions and 39 deletions.
71 changes: 32 additions & 39 deletions resources/js/components/modals/attribute/MultiEdit.vue
Original file line number Diff line number Diff line change
@@ -1,54 +1,51 @@
<template>
<vue-final-modal
classes="modal-container modal"
content-class="sp-modal-content sp-modal-content-xl"
v-model="state.show"
class="modal-container modal"
name="multi-edit-attribute-modal">
<div class="modal-header">
<h5 class="modal-title">
{{
t('main.entity.modals.multiedit.title')
}}
</h5>
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal" @click="closeModal()">
</button>
</div>
<div class="modal-body nonscrollable">
<attribute-list
class="pt-2 h-100 scroll-y-auto scroll-x-hidden"
v-if="state.attributesInitialized"
v-dcan="'entity_data_read'"
:ref="el => listRef = el"
:attributes="state.sortedAttributes"
:values="state.defaultValues"
:selections="state.attributeSelections"
:disable-drag="true"
@dirty="setDirtyState"
/>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-outline-success" :disabled="!state.isDirty" @click="confirm()">
<i class="fas fa-fw fa-save"></i> {{ t('global.save') }}
</button>
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal" @click="closeModal()">
<i class="fas fa-fw fa-times"></i> {{ t('global.cancel') }}
</button>
<div class="sp-modal-content sp-modal-content-xl">
<div class="modal-header">
<h5 class="modal-title">
{{
t('main.entity.modals.multiedit.title')
}}
</h5>
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal" @click="closeModal()">
</button>
</div>
<div class="modal-body">
<attribute-list
class="pt-2 h-100 scroll-y-auto scroll-x-hidden"
v-if="state.attributesInitialized"
v-dcan="'entity_data_read'"
:ref="el => listRef = el"
:attributes="state.sortedAttributes"
:values="state.defaultValues"
:selections="state.attributeSelections"
:disable-drag="true"
@dirty="setDirtyState"
/>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-outline-success" :disabled="!state.isDirty" @click="confirm()">
<i class="fas fa-fw fa-save"></i> {{ t('global.save') }}
</button>
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal" @click="closeModal()">
<i class="fas fa-fw fa-times"></i> {{ t('global.cancel') }}
</button>
</div>
</div>
</vue-final-modal>
</template>

<script>
import {
computed,
onMounted,
reactive,
ref,
toRefs,
} from 'vue';
import { useI18n } from 'vue-i18n';
import store from "@/bootstrap/store.js";
import {
can,
getAttributeSelections,
Expand Down Expand Up @@ -82,20 +79,17 @@
const values = listRef.value.getDirtyValues();
state.show = false;
context.emit('confirm', {
values: values,
});
};
const closeModal = _ => {
state.show = false;
context.emit('closing', false);
};
// DATA
const listRef = ref({});
const state = reactive({
show: false,
attributesInitialized: false,
isDirty: false,
sortedAttributes: attributes.value.sort((a, b) => a.id > b.id),
Expand All @@ -105,7 +99,6 @@
// ON MOUNTED
onMounted(_ => {
state.show = true;
for(let i=0; i<state.sortedAttributes.length; i++) {
const curr = state.sortedAttributes[i];
state.defaultValues[curr.id] = {
Expand Down

0 comments on commit 8b4d66b

Please sign in to comment.