Browse Source

حذف دنبال کنندگان

hgh 1 year ago
parent
commit
4193685822
2 changed files with 52 additions and 3 deletions
  1. 18 1
      src/api/models/Subscription.js
  2. 34 2
      src/pages/Admin/Unit/show.vue

+ 18 - 1
src/api/models/Subscription.js

@@ -10,7 +10,8 @@ export default class SubscriptionAPI extends APIRepository {
       byId: (id) => '/mma/subscriptions/' + id,
       myCorrespondingSubscription: '/mma/subscriptions/my_corresponding_subscription',
       sendMessage: '/mma/subscriptions/send_message',
-      exportReport: '/mma/subscriptions/export_report'
+      exportReport: '/mma/subscriptions/export_report',
+      deleteAll: '/mma/subscriptions/delete_all'
     }
     this.restUrl = (id) => this.url + '/' + id
     /* Setting the callback functions for the CRUD operations. */
@@ -70,6 +71,22 @@ export default class SubscriptionAPI extends APIRepository {
     })
   }
 
+  deleteAllSubscriptions(data) {
+    return this.sendRequest({
+      apiMethod: 'delete',
+      api: this.api,
+      request: this.APIAdresses.deleteAll,
+      data: this.getNormalizedSendData({
+      }, data),
+      resolveCallback: (response) => {
+        return response.data
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
   exportSubscriptionsListReport(data) {
     return this.sendRequest({
       apiMethod: 'get',

+ 34 - 2
src/pages/Admin/Unit/show.vue

@@ -202,8 +202,9 @@
                       :show-search-button="false"
                       :show-expand-button="false">
           <template #toolbar>
-            <div class="flex justify-end">
-              <q-btn color="primary"
+            <div class="flex flex-nowrap justify-end">
+              <q-btn class="q-ml-sm"
+                     color="primary"
                      outline
                      :loading="exportReportLoading"
                      @click="getSubscriptionsListExcel">
@@ -215,6 +216,17 @@
                      @click="showAlertDialog = true" />
             </div>
           </template>
+          <template #before-index-table>
+            <div class="flex flex-nowrap justify-end"
+                 style="margin-bottom: 16px; margin-left: 16px">
+              <q-btn color="red"
+                     outline
+                     :loading="deleteAllLoading"
+                     @click="deleteAllSubscriptions">
+                حذف همه دنبال کنندگان
+              </q-btn>
+            </div>
+          </template>
           <template #after-index-table>
             <q-separator class="q-my-lg" />
           </template>
@@ -316,6 +328,7 @@ export default {
       tab: 'UnitInfo',
       mounted: false,
       exportReportLoading: false,
+      deleteAllLoading: false,
       showAlertDialog: false,
       alertMessageText: '',
       sendingAlertConfirmation: false,
@@ -595,6 +608,25 @@ export default {
     this.mounted = true
   },
   methods: {
+    deleteAllSubscriptions () {
+      this.deleteAllLoading = true
+      APIGateway.subscription.deleteAllSubscriptions({
+        source_type: 'UNIT',
+        source_id: this.$route.params.id
+      })
+        .then(() => {
+          this.$refs.subscriptionsEntityIndex.search()
+          this.$q.notify({
+            type: 'positive',
+            message: 'دنبال کنندگان حذف شدند',
+            position: 'center'
+          })
+          this.deleteAllLoading = false
+        })
+        .catch((e) => {
+          this.deleteAllLoading = false
+        })
+    },
     getSubscriptionsListExcel () {
       this.exportReportLoading = true
       const status = null