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