Explorar el Código

اضافه کردن ویجت

AlertMe.vue

OptionPanel.vue
hgh hace 1 año
padre
commit
6f15a5032c

+ 12 - 3
src/components/Widgets/AlertMe/AlertMe.vue

@@ -5,7 +5,7 @@
               checked-icon="notifications"
               unchecked-icon="notifications_off"
               color="primary"
-              :label="`اطلاع‌رسانی درس سطح یک`"
+              :label="localOptions.sourceTitle"
               left-label
               :disable="loading"
               @update:model-value="onToggle">
@@ -29,11 +29,13 @@
 
 <script>
 import LoginComponent from 'src/components/Auth/LoginComponent.vue'
+import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway'
 
 export default {
   name: 'NotificationToggle',
   components: { LoginComponent },
+  mixins: [mixinWidget],
   props: {
     initialState: {
       type: Boolean,
@@ -42,8 +44,6 @@ export default {
   },
   data () {
     return {
-      sourceType: 'UNIT',
-      sourceId: 1,
       // is_enabled: this.initialState,
       is_enabled: false,
       loading: false,
@@ -51,12 +51,21 @@ export default {
       isUserLogin: false
     }
   },
+  computed: {
+    sourceType() {
+      return this.localOptions.sourceType
+    },
+    sourceId() {
+      return this.localOptions.sourceId
+    }
+  },
   mounted () {
     this.loadAuthData()
     if (this.isUserLogin) {
       this.fetchNotificationStatus()
     }
   },
+
   methods: {
     loadAuthData () { // prevent Hydration node mismatch
       this.user = this.$store.getters['Auth/user']

+ 4 - 2
src/components/Widgets/AlertMe/OptionPanel.vue

@@ -14,7 +14,8 @@
       </div>
       <div class="row">
         <div class="col-md-8 col-12">
-          <q-input v-model="localOptions.sourceType" />
+          <q-select v-model="localOptions.sourceType"
+                    :options="sourceTypeOptions" />
         </div>
       </div>
       <div class="q-mt-md">
@@ -42,8 +43,9 @@ export default defineComponent({
   mixins: [mixinOptionPanel],
   data () {
     return {
+      sourceTypeOptions: ['UNIT'],
       defaultOptions: {
-        sourceTitle: 'عنوان دلخواه',
+        sourceTitle: '',
         sourceType: null,
         sourceId: null
       }