@mapomodule/uikit 1.0.0-alpha.5 → 1.0.0-alpha.6

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.
@@ -1,68 +1,19 @@
1
1
  <template>
2
- <div v-if="compFilters.length">
3
- <v-menu offset-y nudge-right="380px" max-width="400px" tile :close-on-content-click="false" v-bind="{ ...$attrs, value: null }" >
4
- <template v-slot:activator="{ on }">
5
- <v-row class="flex-sm-row-reverse">
6
- <v-col cols="12" sm="3" class="d-flex justify-end align-center">
2
+ <div v-if="compFilters.length" class="main">
3
+ <v-row class="flex-sm-row-reverse">
4
+ <v-col cols="12" sm="3" class="d-flex justify-end align-center">
5
+ <v-menu offset-y min-width="250px" max-width="400px" nudge-top="-5px" tile :close-on-content-click="false" v-bind="{ ...$attrs, value: null }" >
6
+ <template v-slot:activator="{ on }">
7
7
  <v-btn v-bind="$attrs" v-on="on" text>
8
8
  filter <v-icon>mdi-filter-variant</v-icon>
9
9
  </v-btn>
10
- </v-col>
11
- <v-col v-if="activeFilters.length" cols="12" sm="9">
12
- <v-slide-group v-bind="$attrs" show-arrows>
13
- <v-chip
14
- v-bind="$attrs"
15
- class="ma-1"
16
- close
17
- label
18
- @click:close="removeFilter(filter)"
19
- v-for="(filter, i) in activeFilters"
20
- :key="i"
21
- >
22
- <span>
23
- <small>
24
- <b>{{ filter.text.toUpperCase() }}: </b>
25
- {{ formatActiveChoices(filter.active).toUpperCase() }}
26
- </small>
27
- </span>
28
- </v-chip>
29
- </v-slide-group>
30
- </v-col>
31
- </v-row>
32
- </template>
10
+ </template>
33
11
 
34
- <v-list class="pa-0">
35
- <div v-for="(filter, index) in compFilters" :key="index">
36
- <!-- This is a dynamic slot. You can use it to override filters. <br> For example use `filter.status` to completely override the rendering of the filter with `"status"` as value. -->
37
- <slot
38
- :name="`filter.${filter.value}`"
39
- v-bind="{
40
- filter,
41
- addFilter,
42
- removeFilterChoice,
43
- toggleChoice,
44
- activeFilters,
45
- }"
46
- >
47
- <v-list-group>
48
- <v-list-item-title slot="activator">
49
- <!-- This is a dynamic slot. You can use it to override filters title. -->
50
- <slot
51
- :name="`filter.${filter.value}.title`"
52
- v-bind="{
53
- filter,
54
- addFilter,
55
- removeFilterChoice,
56
- toggleChoice,
57
- activeFilters,
58
- }"
59
- >
60
- {{ filter.text }}
61
- </slot>
62
- </v-list-item-title>
63
- <!-- This is a dynamic slot. You can use it to override filters content.-->
12
+ <v-list class="pa-0">
13
+ <div v-for="(filter, index) in compFilters" :key="index">
14
+ <!-- This is a dynamic slot. You can use it to override filters. <br> For example use `filter.status` to completely override the rendering of the filter with `"status"` as value. -->
64
15
  <slot
65
- :name="`filter.${filter.value}.content`"
16
+ :name="`filter.${filter.value}`"
66
17
  v-bind="{
67
18
  filter,
68
19
  addFilter,
@@ -71,63 +22,115 @@
71
22
  activeFilters,
72
23
  }"
73
24
  >
74
- <div v-if="filter.datepicker" class="d-flex flex-column align-end justify-center pb-2">
75
- <v-date-picker
76
- @input="addDateFilter(filter)"
77
- class="rounded-0"
78
- v-model="filter.dates"
79
- range
80
- full-width
81
- no-title
82
- color="primary"
83
- >
84
- </v-date-picker>
85
- <v-btn
86
- class="datapicker-clear-btn elevation-0"
87
- @click="removeFilter(filter)"
88
- small
89
- tile
90
- >clear</v-btn
91
- >
92
- </div>
93
- <v-list v-else class="overflow-y-auto pa-0" max-height="200" dense>
94
- <v-list-item
95
- v-for="(choice, i) in filter.choices"
96
- :key="i"
97
- class="v-list-item--link"
98
- active-class="primary--text"
99
- :input-value="isChoiceActive(filter, choice)"
100
- @click.native.stop="toggleChoice(filter, choice)"
101
- >
102
- <!-- This is a dynamic slot. You can use it to override filters icon. -->
25
+ <v-list-group>
26
+ <v-list-item-title slot="activator">
27
+ <!-- This is a dynamic slot. You can use it to override filters title. -->
103
28
  <slot
104
- :name="`filter.${filter.value}.icon`"
105
- v-bind="{ filter, choice }"
29
+ :name="`filter.${filter.value}.title`"
30
+ v-bind="{
31
+ filter,
32
+ addFilter,
33
+ removeFilterChoice,
34
+ toggleChoice,
35
+ activeFilters,
36
+ }"
106
37
  >
107
- <v-list-item-icon>
108
- <v-icon
109
- v-text="choice.icon || 'mdi-circle-small'"
110
- ></v-icon>
111
- </v-list-item-icon>
38
+ {{ filter.text }}
112
39
  </slot>
40
+ </v-list-item-title>
41
+ <!-- This is a dynamic slot. You can use it to override filters content.-->
42
+ <slot
43
+ :name="`filter.${filter.value}.content`"
44
+ v-bind="{
45
+ filter,
46
+ addFilter,
47
+ removeFilterChoice,
48
+ toggleChoice,
49
+ activeFilters,
50
+ }"
51
+ >
52
+ <div v-if="filter.datepicker" class="d-flex flex-column align-end justify-center pb-2">
53
+ <v-date-picker
54
+ @input="addDateFilter(filter)"
55
+ class="rounded-0"
56
+ v-model="filter.dates"
57
+ range
58
+ full-width
59
+ no-title
60
+ color="primary"
61
+ >
62
+ </v-date-picker>
63
+ <v-btn
64
+ class="datapicker-clear-btn elevation-0"
65
+ @click="removeFilter(filter)"
66
+ small
67
+ tile
68
+ >clear</v-btn
69
+ >
70
+ </div>
71
+ <v-list v-else class="overflow-y-auto pa-0" max-height="200" dense>
72
+ <v-list-item
73
+ v-for="(choice, i) in filter.choices"
74
+ :key="i"
75
+ class="v-list-item--link"
76
+ active-class="primary--text"
77
+ :input-value="isChoiceActive(filter, choice)"
78
+ @click.native.stop="toggleChoice(filter, choice)"
79
+ >
80
+ <!-- This is a dynamic slot. You can use it to override filters icon. -->
81
+ <slot
82
+ :name="`filter.${filter.value}.icon`"
83
+ v-bind="{ filter, choice }"
84
+ >
85
+ <v-list-item-icon>
86
+ <v-icon
87
+ v-text="choice.icon || 'mdi-circle-small'"
88
+ ></v-icon>
89
+ </v-list-item-icon>
90
+ </slot>
113
91
 
114
- <v-list-item-content>
115
- <v-list-item-title
116
- v-text="choice.text"
117
- ></v-list-item-title>
118
- </v-list-item-content>
119
- </v-list-item>
120
- </v-list>
92
+ <v-list-item-content>
93
+ <v-list-item-title
94
+ v-text="choice.text"
95
+ ></v-list-item-title>
96
+ </v-list-item-content>
97
+ </v-list-item>
98
+ </v-list>
99
+ </slot>
100
+ </v-list-group>
121
101
  </slot>
122
- </v-list-group>
123
- </slot>
124
- </div>
125
- </v-list>
126
- </v-menu>
102
+ </div>
103
+ </v-list>
104
+ </v-menu>
105
+ </v-col>
106
+ <v-col v-if="activeFilters.length" cols="12" sm="9">
107
+ <v-slide-group v-bind="$attrs" show-arrows>
108
+ <v-chip
109
+ v-bind="$attrs"
110
+ class="ma-1"
111
+ close
112
+ label
113
+ @click:close="removeFilter(filter)"
114
+ v-for="(filter, i) in activeFilters"
115
+ :key="i"
116
+ >
117
+ <span>
118
+ <small>
119
+ <b>{{ filter.text.toUpperCase() }}: </b>
120
+ {{ formatActiveChoices(filter.active).toUpperCase() }}
121
+ </small>
122
+ </span>
123
+ </v-chip>
124
+ </v-slide-group>
125
+ </v-col>
126
+ </v-row>
127
127
  </div>
128
128
  </template>
129
129
 
130
130
  <style lang="scss" scoped>
131
+ .main{
132
+ width: 100%;
133
+ }
131
134
  .datapicker-clear-btn {
132
135
  margin: -20px 15px 0 0 ;
133
136
  }
@@ -159,9 +162,10 @@ export default {
159
162
  methods: {
160
163
  addDateFilter(filter) {
161
164
  const { dates } = filter;
165
+ dates.sort((a,b) => Date.parse(a) - Date.parse(b));
162
166
  if (dates && dates.length > 1) {
163
167
  this.addFilter(filter, {
164
- text: dates.join(" ~ "),
168
+ text: dates.map(date => new Date(date).toLocaleDateString()).join(" ~ "),
165
169
  value: dates.join(","),
166
170
  });
167
171
  } else if (!dates || !dates.length) {
@@ -245,7 +249,6 @@ export default {
245
249
  if (index !== -1) {
246
250
  let filter = this.compFilters[index];
247
251
  if (filter.datepicker) {
248
- filter = { ...filter };
249
252
  filter.dates = [...this.$route.query[k].split(",")];
250
253
  this.addDateFilter(filter);
251
254
  } else {
@@ -257,6 +260,17 @@ export default {
257
260
  }
258
261
  });
259
262
  },
263
+ loadFilters() {
264
+ this.compFilters = this.filters.map(filter => {
265
+ if (filter.datepicker) {
266
+ return {
267
+ ...filter,
268
+ dates: [],
269
+ };
270
+ }
271
+ return filter;
272
+ });
273
+ }
260
274
  },
261
275
  watch: {
262
276
  activeFilters: {
@@ -268,8 +282,8 @@ export default {
268
282
  }, 200),
269
283
  },
270
284
  },
271
- mounted() {
272
- this.compFilters = this.filters;
285
+ created() {
286
+ this.loadFilters();
273
287
  this.restoreFromQparams();
274
288
  },
275
289
  };
@@ -278,7 +292,7 @@ export default {
278
292
  <docs>
279
293
  ## Filter config
280
294
 
281
- The filters prop is a list of `Filter` objects made of several keys:
295
+ The filters prop is a list of `Filter` objects made of several keys:
282
296
 
283
297
  - **"text"** `String` ==> The name of the filter that will be renered inside the filter menu.
284
298
  - **"value"** `String` ==> The dotted path of the value we need to filter on.
@@ -317,4 +331,4 @@ const filters = [
317
331
  },
318
332
  ]
319
333
  ```
320
- </docs>
334
+ </docs>
@@ -1,13 +1,15 @@
1
1
  <template>
2
2
  <div class="list__head">
3
3
  <h2 class="list__head__title display-1">{{ title }}</h2>
4
- <v-btn
5
- v-if="addItem"
6
- class="rounded-0 elevation-0"
7
- color="primary"
8
- :to="{path: `${$route.path}/new`}"
9
- >Add new <v-icon>mdi-plus</v-icon></v-btn
10
- >
4
+ <div class="list__head__button">
5
+ <v-btn
6
+ v-if="addItem"
7
+ class="rounded-0 elevation-0"
8
+ color="primary"
9
+ :to="{ path: `${$route.path}/new` }"
10
+ >Add new &emsp; <v-icon>mdi-plus</v-icon></v-btn
11
+ >
12
+ </div>
11
13
  </div>
12
14
  </template>
13
15
 
@@ -18,10 +20,18 @@
18
20
  &__head {
19
21
  display: flex;
20
22
  align-items: center;
21
- justify-content: flex-start;
22
- margin-bottom: 4rem;
23
+ justify-content: space-between;
24
+ flex-wrap: wrap;
25
+ margin-bottom: 2rem;
23
26
  &__title {
24
27
  margin-right: 2rem;
28
+ margin-bottom: 1rem;
29
+ }
30
+ &__button {
31
+ display: flex;
32
+ flex: 1;
33
+ justify-content: flex-end;
34
+ margin-bottom: 1rem;
25
35
  }
26
36
  }
27
37
  }
@@ -40,10 +50,10 @@ export default {
40
50
  // The route name.
41
51
  default() {
42
52
  return this.$route.name;
43
- },
53
+ }
44
54
  },
45
55
  // This is a boolean that determines the visibility of "new item" button. If set to true will provide the user a link to a detail page for new content creation.
46
- addItem: Boolean,
47
- },
56
+ addItem: Boolean
57
+ }
48
58
  };
49
59
  </script>
@@ -84,8 +84,9 @@ export default {
84
84
  },
85
85
  crud: {
86
86
  type: Object,
87
- required: true,
87
+ required: true
88
88
  },
89
+ offline: Boolean
89
90
  },
90
91
  watch: {
91
92
  value(val) {
@@ -147,12 +148,20 @@ export default {
147
148
  this.dialog = false;
148
149
  },
149
150
  apiEdit() {
150
- return this.crud
151
- .partialUpdate(this.itemRef[this.lookup], this.editedItem)
152
- .then((res) => this.close(res));
151
+ if (!this.offline) {
152
+ return this.crud
153
+ .partialUpdate(this.itemRef[this.lookup], this.editedItem)
154
+ .then((res) => this.close(res));
155
+ } else {
156
+ this.close(this.editedItem);
157
+ }
153
158
  },
154
159
  apiCreate() {
155
- return this.crud.create(this.editedItem).then((res) => this.close(res));
160
+ if (!this.offline) {
161
+ return this.crud.create(this.editedItem).then((res) => this.close(res));
162
+ } else {
163
+ return this.close(this.editedItem);
164
+ }
156
165
  },
157
166
  },
158
167
  };