소스 검색

fixed #394

ali 2 년 전
부모
커밋
2bd6dbe9d2
1개의 변경된 파일과 42개의 추가작업 그리고 5개의 파일을 삭제
  1. 42 5
      src/components/Widgets/FAQ/OptionPanel.vue

+ 42 - 5
src/components/Widgets/FAQ/OptionPanel.vue

@@ -6,11 +6,27 @@
                         expand-separator>
         <template #header>
           <div class="full-width">
-            <q-btn icon="remove"
-                   flat
-                   @click="removeTopic(topicIndex)">
-              حذف موضوع
-            </q-btn>
+            <q-btn icon="expand_less"
+                   color="info"
+                   dense
+                   size="sm"
+                   outline
+                   class="q-ml-md"
+                   @click="increaseOrder($event, topicIndex)" />
+            <q-btn icon="expand_more"
+                   color="info"
+                   dense
+                   size="sm"
+                   outline
+                   class="q-mr-xl"
+                   @click="decreaseOrder($event, topicIndex)" />
+            <q-btn icon="delete"
+                   color="red"
+                   dense
+                   size="sm"
+                   outline
+                   class="q-mr-md"
+                   @click="removeTopic(topicIndex)" />
             (
             <q-icon :name="localOptions.topics[topicIndex].icon"
                     size="30px" />
@@ -83,6 +99,27 @@ export default defineComponent({
     }
   },
   methods: {
+    increaseOrder(event, index) {
+      event.stopPropagation()
+      if (index <= 0) {
+        return
+      }
+
+      // Swap the item with the previous item
+      const temp = this.localOptions.topics[index - 1]
+      this.localOptions.topics[index - 1] = this.localOptions.topics[index]
+      this.localOptions.topics[index] = temp
+    },
+    decreaseOrder(event, index) {
+      event.stopPropagation()
+      if (index >= this.localOptions.topics.length - 1) {
+        return
+      }
+      // Swap the item with the next item
+      const temp = this.localOptions.topics[index + 1]
+      this.localOptions.topics[index + 1] = this.localOptions.topics[index]
+      this.localOptions.topics[index] = temp
+    },
     addTopic () {
       this.localOptions.topics.push({
         title: '',