Commit c2208792 authored by Julien BOUYER's avatar Julien BOUYER
Browse files

UNOTOPLYS-171 feat(screen) : calcul des index au réordonnancement des écrans...

UNOTOPLYS-171 feat(screen) : calcul des index au réordonnancement des écrans et rafraîchissement de la liste
parent a9837ad2
......@@ -45,7 +45,12 @@ export default class DndList extends Vue {
public reordered(e: CustomEvent) {
const selectedElm = e.detail.items[0];
const screen = this.screenList.find(s => s.id === Number.parseInt(selectedElm.getAttribute('data-screenid'), 10));
this.$emit('update', { screen, newIndex: e.detail.index });
const screenIdx = this.screenList.findIndex(s => s.id === Number.parseInt(selectedElm.getAttribute('data-screenid'), 10));
const screen = this.screenList[screenIdx];
let newIndex = e.detail.index;
if (newIndex <= screenIdx) {
newIndex++;
}
this.$emit('update', { screen, newIndex });
}
}
import Vue from 'vue';
import { Component, Inject } from 'vue-property-decorator';
import { Component, Inject, Watch } from 'vue-property-decorator';
import { IScreen } from '@/shared/model/screen.model';
import ScreenService from '@/entities/screen/screen.service';
......@@ -18,19 +18,28 @@ import Icon from '@/components/icon/icon.vue';
export default class Panel extends Vue {
@Inject('screenService') private screenService: () => ScreenService;
public screenList: any[];
public dndKey: number;
public showConfirm: boolean;
constructor() {
super();
this.screenList = this.$store.getters.screenList || [];
this.dndKey = 0;
this.showConfirm = false;
}
public get screenList(): any[] {
return this.$store.getters.screenList;
@Watch('$store.getters.screenList')
public reloadScreenList() {
this.screenList = this.$store.getters.screenList;
this.dndKey += 1;
}
public updateScreenIndex({ screen, newIndex }) {
this.$store.dispatch('updateScreenIndex', { screen, newIndex });
this.dndKey += 1;
}
public get idWorkspace(): string {
......
......@@ -23,7 +23,7 @@
@confirm="deleteScreen"
/>
</div>
<dnd-list :screenList="screenList" :idScreen="idScreen" @update="updateScreenIndex" @selectScreen="selectScreen" />
<dnd-list :screenList="screenList" :idScreen="idScreen" @update="updateScreenIndex" @selectScreen="selectScreen" :key="dndKey" />
</div>
</aside>
</template>
......
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