@7365admin1/layer-common 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "commit": false,
5
5
  "fixed": [],
6
6
  "linked": [],
7
- "access": "restricted",
7
+ "access": "public",
8
8
  "baseBranch": "main",
9
9
  "updateInternalDependencies": "patch",
10
10
  "ignore": []
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 1.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 5db6d60: Updated npm account to 7365admin1 and changed package name from @iservice365/layer-common to @7365admin1/layer-common
8
+
3
9
  ## 1.8.0
4
10
 
5
11
  ### Minor Changes
package/app.vue CHANGED
@@ -1,3 +1,3 @@
1
1
  <template>
2
- <h1>Common Layer</h1>
2
+ <h1>Common Layer v2</h1>
3
3
  </template>
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <v-card width="100%" :disabled="loading" :loading="loading">
3
+ <v-card-text style="max-height: 100vh; overflow-y: auto" class="pa-5 my-5 px-7 text-center">
4
+ <v-row no-gutters>
5
+ <v-col cols="12" class="text-h6 font-weight-bold">
6
+ <span class=""> {{ promptTitle }}</span>
7
+ </v-col>
8
+ <v-col v-if="message" cols="12" class="mt-5">
9
+ <span >
10
+ {{ message }}
11
+ </span>
12
+ </v-col>
13
+ </v-row>
14
+ </v-card-text>
15
+
16
+ <v-toolbar class="pa-0" density="compact">
17
+ <v-row no-gutters>
18
+ <v-col cols="6" class="pa-0">
19
+ <v-btn block variant="text" class="text-none" size="large" tile @click="emit('close')" height="48">
20
+ Cancel
21
+ </v-btn>
22
+ </v-col>
23
+
24
+ <v-col cols="6" class="pa-0">
25
+ <v-btn block tile variant="flat" class="text-none" size="large" height="48"
26
+ :color="confirmButtonColor" @click="emit('proceed')">
27
+ {{ confirmLabel }}
28
+ </v-btn>
29
+ </v-col>
30
+ </v-row>
31
+ </v-toolbar>
32
+ </v-card>
33
+ </template>
34
+
35
+ <script setup lang="ts">
36
+ const props = defineProps({
37
+ message: {
38
+ type: String,
39
+ default: ""
40
+ },
41
+ promptTitle: {
42
+ type: String,
43
+ default: "Are you sure want to delete this? "
44
+ },
45
+ loading: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ confirmLabel: {
50
+ type: String,
51
+ default: "Proceed"
52
+ },
53
+ confirmButtonColor: {
54
+ type: String,
55
+ default: "black"
56
+ }
57
+
58
+ })
59
+
60
+ const emit = defineEmits(["close", "proceed"])
61
+
62
+ </script>
63
+
64
+ <style scoped></style>
@@ -1,20 +1,25 @@
1
1
  <template>
2
- <v-row no-gutters>
3
- <v-form v-model="valid">
4
- <v-row>
5
- <v-col cols="6">
6
- <InputLabel class="text-capitalize font-weight-bold" :title="title" :required="required" />
7
- <v-text-field v-model.number="count" type="number" density="comfortable" :rules="rules" />
8
- </v-col>
9
-
10
- <v-col cols="6">
11
- <v-btn color="primary" class="text-none mt-6" size="large" variant="flat"
12
- :disabled="!valid || disabled" :loading="loading || updating" text="Save" @click="handleSave" />
13
- </v-col>
14
- </v-row>
15
- </v-form>
16
- <Snackbar v-model="toastObject.show" :text="toastObject.message" :color="toastObject.color" />
17
- </v-row>
2
+ <v-row no-gutters>
3
+ <v-form v-model="valid">
4
+ <v-row>
5
+ <v-col cols="6">
6
+ <InputLabel class="text-capitalize font-weight-bold" :title="title" :required="required" />
7
+ <v-text-field v-model.number="count" type="number" density="comfortable" :rules="rules" />
8
+ </v-col>
9
+
10
+ <v-col cols="6">
11
+ <v-btn color="primary" class="text-none mt-6" size="large" variant="flat"
12
+ :disabled="!valid || disabled" :loading="loading || updating" text="Save" @click="handleSave" />
13
+ </v-col>
14
+ </v-row>
15
+ </v-form>
16
+ <Snackbar v-model="toastObject.show" :text="toastObject.message" :color="toastObject.color" />
17
+ <v-dialog v-model="dialog.updateBlockPrompt" persistent max-width="450">
18
+ <DialogReusablePrompt :promptTitle="`Reduce number of ${props.type === 'blocks' ? 'blocks' : 'guard posts'}?`" confirm-button-color="red"
19
+ :message="`Lowering the ${props.type === 'blocks' ? 'block' : 'guard post'} count will remove option beyond the new limit. Are you sure you want to proceed?`"
20
+ @close="dialog.updateBlockPrompt = false" @proceed="handleProceedSave" />
21
+ </v-dialog>
22
+ </v-row>
18
23
  </template>
19
24
 
20
25
  <script setup lang="ts">
@@ -24,9 +29,11 @@ const props = defineProps({
24
29
  title: { type: String, required: true },
25
30
  required: { type: Boolean, default: true },
26
31
  loading: { type: Boolean, default: false },
27
- type: { type: String as PropType<'blocks' | 'guard_posts'>, required: true},
28
- disabled: {type: Boolean, default: false},
29
- siteId: { type: String, required: true }
32
+ type: { type: String as PropType<'blocks' | 'guard_posts'>, required: true },
33
+ disabled: { type: Boolean, default: false },
34
+ siteId: { type: String, required: true },
35
+ existingBlockNumber: { type: Number, default: 0 },
36
+ existingGuardPostsNumber: { type: Number, default: 0 },
30
37
  });
31
38
 
32
39
  const { updateSite, setSiteGuardPosts } = useSiteSettings()
@@ -37,11 +44,15 @@ const valid = ref(false);
37
44
  const updating = ref(false)
38
45
 
39
46
  const toastObject = reactive({
40
- show: false,
41
- message: "",
42
- color: "",
47
+ show: false,
48
+ message: "",
49
+ color: "",
43
50
  });
44
51
 
52
+ const dialog = reactive({
53
+ updateBlockPrompt: false,
54
+ })
55
+
45
56
 
46
57
  const emits = defineEmits(["success", "error"]);
47
58
 
@@ -62,46 +73,68 @@ const rules = computed(() => {
62
73
  });
63
74
 
64
75
 
76
+ function handleSave() {
77
+ const previousCount =
78
+ props.type === 'blocks'
79
+ ? props.existingBlockNumber
80
+ : props.type === 'guard_posts'
81
+ ? props.existingGuardPostsNumber
82
+ : null;
83
+
84
+ if (!previousCount) {
85
+ handleProceedSave();
86
+ return;
87
+ }
88
+
89
+ if (count.value < previousCount) {
90
+ dialog.updateBlockPrompt = true;
91
+ return;
92
+ }
93
+
94
+ handleProceedSave();
95
+ }
96
+
65
97
 
66
98
 
67
- async function handleSave() {
68
- if(!props.siteId){
99
+ async function handleProceedSave() {
100
+ if (!props.siteId) {
69
101
  return emits('error', 'Site ID is required')
70
102
  }
71
103
 
104
+ dialog.updateBlockPrompt = false;
72
105
  updating.value = true;
73
106
 
74
107
  try {
75
- if(props.type === 'blocks'){
76
- await updateSite(props.siteId, { block: count.value});
77
- handleSuccess('The number of blocks has been updated successfully!')
78
- } else if (props.type) {
79
- await setSiteGuardPosts(props.siteId, count.value)
80
- handleSuccess('The number of guard posts has been updated successfully!')
81
-
82
- } else {
83
- throw new Error('Invalid type Prop provided.')
108
+ if (props.type === 'blocks') {
109
+ await updateSite(props.siteId, { block: count.value });
110
+ handleSuccess('The number of blocks has been updated successfully!')
111
+ } else if (props.type) {
112
+ await setSiteGuardPosts(props.siteId, count.value)
113
+ handleSuccess('The number of guard posts has been updated successfully!')
114
+
115
+ } else {
116
+ throw new Error('Invalid type Prop provided.')
117
+ }
118
+
119
+ emits('success')
120
+ } catch (error: any) {
121
+ const message = error?.data?.message || `Error updating ${props.type.replace('_', ' ')}`;
122
+ handleError(message)
123
+ } finally {
124
+ updating.value = false;
84
125
  }
85
-
86
- emits('success')
87
- } catch (error: any) {
88
- const message = error?.data?.message || `Error updating ${props.type.replace('_', ' ')}`;
89
- handleError(message)
90
- } finally {
91
- updating.value = false;
92
- }
93
126
  }
94
127
 
95
128
  const handleSuccess = (message: string) => {
96
- toastObject.show = true;
97
- toastObject.message = message;
98
- toastObject.color = "success";
129
+ toastObject.show = true;
130
+ toastObject.message = message;
131
+ toastObject.color = "success";
99
132
  };
100
133
 
101
134
  const handleError = (message: string) => {
102
- toastObject.show = true;
103
- toastObject.message = message;
104
- toastObject.color = "error";
135
+ toastObject.show = true;
136
+ toastObject.message = message;
137
+ toastObject.color = "error";
105
138
  };
106
139
 
107
140
  </script>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.8.0",
5
+ "version": "1.8.1",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {
File without changes
File without changes
File without changes
File without changes
File without changes