@hostlink/nuxt-light 0.0.117 → 1.0.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.
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.117"
4
+ "version": "1.0.1"
5
5
  }
@@ -40,7 +40,7 @@ const attrs = {
40
40
  }
41
41
  </script>
42
42
  <template>
43
- <q-input v-bind="attrs" v-model="localValue">
43
+ <q-input v-bind="attrs" v-model="localValue" hide-bottom-space>
44
44
  <q-dialog v-model="show" full-height full-width>
45
45
  <l-file-manager closable @close="show = false" @input="onInput"></l-file-manager>
46
46
  </q-dialog>
@@ -1,7 +1,7 @@
1
1
  <script setup>
2
2
  import { ref } from 'vue'
3
3
  import { useRouter, useRoute } from "vue-router";
4
- import { Dialog } from "quasar";
4
+ import { Dialog, Notify } from "quasar";
5
5
  import { model } from "@hostlink/light"
6
6
 
7
7
  const route = useRoute();
@@ -40,11 +40,21 @@ if (!props.context.onSubmit) {
40
40
  try {
41
41
  if (route.params[id_name]) {//edit
42
42
  if (await model(module).update(parseInt(route.params[id_name]), v)) {
43
+ Notify.create({
44
+ message: "Updated successfully",
45
+ color: "positive",
46
+ icon: "sym_o_check"
47
+ });
43
48
  router.go(-1);
44
49
  return;
45
50
  }
46
51
  } else {
47
52
  if (await model(module).add(v)) {
53
+ Notify.create({
54
+ message: "Added successfully",
55
+ color: "positive",
56
+ icon: "sym_o_check"
57
+ });
48
58
  router.go(-1);
49
59
  return;
50
60
  }
@@ -67,7 +77,7 @@ if (!props.context.onSubmit) {
67
77
  <form v-bind="context.attrs">
68
78
  <l-card :bordered="bordered">
69
79
  <q-card-section>
70
- <div :class="`q-gutter-${gutter}`">
80
+ <div :class="`q-col-gutter-${gutter}`">
71
81
  <slot v-bind="context"></slot>
72
82
  </div>
73
83
  </q-card-section>
@@ -15,9 +15,28 @@ const value = computed({
15
15
  const ss = Object.entries(useSlots()).map(([key, value]) => {
16
16
  return key;
17
17
  });
18
+
19
+ //check required in parsedRules
20
+ let required = false;
21
+ for (let rule of props.context.node.props.parsedRules ?? []) {
22
+ if (rule.name === "required") {
23
+ required = true;
24
+ break;
25
+ }
26
+ }
27
+
28
+ let clearable = false;
29
+ if (required) { //no clearable
30
+ clearable = false;
31
+ } else {
32
+ clearable = true;
33
+ }
34
+
35
+
18
36
  </script>
19
37
  <template>
20
- <l-select v-model="value" :label="context.label" v-bind="context.attrs" :error="error" :error-message="errorMessage">
38
+ <l-select v-model="value" :label="context.label" v-bind="context.attrs" :error="error" :error-message="errorMessage"
39
+ :clearable="clearable">
21
40
  <template v-for="s in ss" v-slot:[s]="props" :key="s">
22
41
  <slot :name="s" v-bind="props ?? {}"></slot>
23
42
  </template>
@@ -1,24 +1,34 @@
1
1
  <script setup>
2
- import { reactive } from 'vue'
3
2
  import { m } from '../../'
4
- const obj = reactive({})
3
+ import { Notify } from "quasar"
5
4
 
6
- const onSave = async () => {
7
- if (await m("mailTest", obj)) {
8
- que.notify({
9
- message: "Mail sent",
5
+ const onSubmit = async (data) => {
6
+ try {
7
+ await m("mailTest", data)
8
+
9
+
10
+ Notify.create({
11
+ message: "Email sent",
10
12
  color: "positive",
11
- icon: "email"
13
+ icon: "check"
12
14
  });
15
+
16
+ } catch (e) {
17
+ Notify.create({
18
+ message: e.message,
19
+ color: "negative",
20
+ icon: "warning"
21
+ })
13
22
  }
14
23
  }
15
24
  </script>
16
25
  <template>
17
26
  <l-page>
18
- <l-form @save="onSave">
19
- <l-input label="Email" v-model="obj.email" required></l-input>
20
- <l-input label="Subject" v-model="obj.subject" required></l-input>
21
- <l-input type="textarea" label="Content" v-model="obj.content" required></l-input>
22
- </l-form>
27
+ <FormKit type="l-form" @submit="onSubmit">
28
+ <FormKit type="l-input" label="Email" name="email" validation="required|email"></FormKit>
29
+ <FormKit type="l-input" label="Subject" name="subject" validation="required"></FormKit>
30
+ <FormKit type="l-input" input-type="textarea" label="Content" name="content" validation="required">
31
+ </FormKit>
32
+ </FormKit>
23
33
  </l-page>
24
34
  </template>
@@ -1,22 +1,17 @@
1
1
  <script setup>
2
- import { useQuasar } from 'quasar'
2
+ import { Notify } from 'quasar'
3
3
  import { useRouter } from 'vue-router'
4
- import { reactive } from "vue"
5
4
  import { q, m } from '../../'
6
5
 
7
6
  const router = useRouter()
8
- const que = useQuasar()
9
-
10
7
  const { app } = await q({ app: { config: ["name", "value"] } })
11
-
12
- //const system = await q("system", ["passwordPolicy"])
13
-
14
- const obj = reactive(app.config.reduce((acc, cur) => {
8
+ const obj = app.config.reduce((acc, cur) => {
15
9
  acc[cur.name] = cur.value
16
10
  return acc
17
- }, {}));
11
+ }, {});
18
12
 
19
- const fields = ["company", "company_logo", "password_upper_case", "password_lower_case", "password_number", "password_special_character",
13
+ const fields = ["company", "company_logo",
14
+ "password_upper_case", "password_lower_case", "password_number", "password_special_character",
20
15
  "file_manager", "two_factor_authentication"];
21
16
 
22
17
  //filter out fields that are not in the app.config table
@@ -26,53 +21,53 @@ Object.keys(obj).forEach((key) => {
26
21
  }
27
22
  })
28
23
 
29
- const onSave = async () => {
30
- const data = [];
31
- Object.keys(obj).forEach((key) => {
24
+ const onSubmit = async (d, form) => {
25
+ let data = [];
26
+ Object.keys(d).forEach((key) => {
32
27
  data.push({
33
28
  name: key,
34
- value: obj[key]
29
+ value: d[key]
35
30
  })
36
31
  })
32
+
37
33
  await m("updateAppConfigs", { data })
38
34
  //show success
39
- que.notify({
40
- message: "Saved",
41
- type: "positive",
42
- position: "top",
43
- });
44
-
35
+ Notify.create({
36
+ message: "Settings updated",
37
+ color: "positive",
38
+ icon: "check"
39
+ })
45
40
 
46
- }
41
+ router.go(-1);
47
42
 
48
43
 
44
+ }
49
45
  </script>
50
46
  <template>
51
47
  <l-page>
52
- <l-form @save="onSave">
53
- <l-input label="Company" v-model="obj.company"></l-input>
54
- <l-input label="Company logo" v-model="obj.company_logo"></l-input>
48
+
49
+ <FormKit type="l-form" :value="obj" #default="{ value }" @submit="onSubmit">
50
+ <FormKit type="l-input" label="Company" name="company"></FormKit>
51
+ <FormKit type="l-input" label="Company logo" name="company_logo"></FormKit>
55
52
 
56
53
  <q-field label="Password policy" stack-label>
57
- <q-checkbox label="Upper case" v-model="obj.password_upper_case" true-value="1"
58
- false-value="0"></q-checkbox>
59
- <q-checkbox label="Lower case" v-model="obj.password_lower_case" true-value="1"
60
- false-value="0"></q-checkbox>
61
- <q-checkbox label="Number" v-model="obj.password_number" true-value="1" false-value="0"></q-checkbox>
62
- <q-checkbox label="Special character" v-model="obj.password_special_character" true-value="1"
63
- false-value="0"></q-checkbox>
54
+ <FormKit type="q-checkbox" label="Upper Case" name="password_upper_case" true-value="1" false-value="0" />
55
+ <FormKit type="q-checkbox" label="Lower Case" name="password_lower_case" true-value="1" false-value="0" />
56
+ <FormKit type="q-checkbox" label="Number" name="password_number" true-value="1" false-value="0" />
57
+ <FormKit type="q-checkbox" label="Special Character" name="password_special_character" true-value="1"
58
+ false-value="0" />
64
59
  </q-field>
65
60
 
66
61
 
67
62
  <q-field label="File manager" stack-label>
68
- <q-checkbox label="Show" v-model="obj.file_manager" true-value="1" false-value="0"></q-checkbox>
63
+ <FormKit type="q-checkbox" label="Show" name="file_manager" true-value="1" false-value="0" />
69
64
  </q-field>
70
65
 
71
66
  <q-field label="Two factor authentication" stack-label>
72
- <q-checkbox label="Enable" v-model="obj.two_factor_authentication" true-value="1"
73
- false-value="0"></q-checkbox>
67
+ <FormKit type="q-checkbox" label="Enable" name="two_factor_authentication" true-value="1" false-value="0" />
74
68
  </q-field>
75
69
 
76
- </l-form>
70
+
71
+ </FormKit>
77
72
  </l-page>
78
73
  </template>
@@ -4,44 +4,50 @@ import { getObject } from '../../../'
4
4
  const obj = reactive(await getObject(["username", "first_name", "last_name", "email", "phone",
5
5
  "addr1", "addr2", "addr3", "join_date", "expiry_date", "status", "language", "default_page"
6
6
  ]))
7
+
8
+ const options = [
9
+ { label: 'Active', value: 0 },
10
+ { label: 'Inactive', value: 1 }
11
+ ];
12
+
13
+ const languages = [
14
+ { label: 'English', value: 'en' },
15
+ { label: '中文', value: 'zh-hk' }
16
+ ]
17
+
18
+
7
19
  </script>
8
20
 
9
21
  <template>
10
22
  <l-page>
11
- <l-form v-model="obj" gutter="none">
23
+ <FormKit type="l-form" :value="obj">
12
24
  <l-row>
13
25
  <l-col md="6" gutter="md">
14
- <l-input label="Username" v-model="obj.username" required />
15
- <l-input label="First name" v-model="obj.first_name" required />
16
- <l-input label="Last name" v-model="obj.last_name" />
17
- <l-input label="Email" v-model="obj.email" required type="email" />
26
+ <FormKit type="l-input" label="Username" name="username" validation="required" />
27
+ <FormKit type="l-input" label="First name" name="first_name" validation="required" />
28
+ <FormKit type="l-input" label="Last name" name="last_name" />
29
+ <FormKit type="l-input" label="Email" name="email" validation="required|email" />
18
30
  </l-col>
31
+
19
32
  <l-col md="6" gutter="md">
20
- <l-input label="Phone" v-model="obj.phone" />
21
- <l-input label="Address1" v-model="obj.addr1" />
22
- <l-input label="Address2" v-model="obj.addr2" />
23
- <l-input label="Address3" v-model="obj.addr3" />
33
+ <FormKit type="l-input" label="Phone" name="phone" />
34
+ <FormKit type="l-input" label="Address1" name="addr1" />
35
+ <FormKit type="l-input" label="Address2" name="addr2" />
36
+ <FormKit type="l-input" label="Address3" name="addr3" />
24
37
  </l-col>
25
- <l-col gutter="md">
26
- <l-date-picker label="Join date" v-model="obj.join_date" required />
27
- <l-date-picker label="Expiry date" v-model="obj.expiry_date" />
28
38
 
29
- <l-select label="Status" :options="[{ value: 0, label: 'Active' }, { value: 1, label: 'Inactive' }]"
30
- v-model="obj.status" required></l-select>
39
+ <l-col gutter="md">
40
+ <FormKit type="l-date-picker" label="Join date" name="join_date" validation="required" />
41
+ <FormKit type="l-date-picker" label="Expiry date" name="expiry_date" />
42
+ <FormKit type="l-select" label="Status" name="status" :options="options" validation="required" />
43
+ <FormKit type="l-select" label="Language" name="language" :options="languages" validation="required" />
44
+ <FormKit type="l-input" label="Default page" name="default_page" />
31
45
 
32
- <l-select label="Language" :options="[{
33
- label: 'English',
34
- value: 'en'
35
- }, {
36
- label: '中文',
37
- value: 'zh-hk'
38
- }]" v-model="obj.language" required></l-select>
46
+ </l-col>
47
+ </l-row>
39
48
 
40
- <l-input label="Default page" v-model="obj.default_page"></l-input>
49
+ </FormKit>
41
50
 
42
51
 
43
- </l-col>
44
- </l-row>
45
- </l-form>
46
52
  </l-page>
47
53
  </template>
@@ -48,18 +48,11 @@ const languages = [
48
48
  { label: '中文', value: 'zh-hk' }
49
49
  ]
50
50
 
51
- const onSubmit = async (data) => {
52
- return model("User").add(data).then((res) => {
53
- router.push("/User");
54
- }).catch((err) => {
55
- console.log(err)
56
- })
57
- }
58
51
 
59
52
  </script>
60
53
  <template>
61
54
  <l-page>
62
- <FormKit type="l-form" :value="obj" @submit="onSubmit">
55
+ <FormKit type="l-form" :value="obj">
63
56
  <l-row>
64
57
  <l-col md="6" gutter="md">
65
58
  <FormKit type="l-input" label="Username" name="username" validation="required" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.117",
3
+ "version": "1.0.1",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",