quasar-ui-danx 0.0.19 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/components/ActionTable/ActionTable.vue +1 -1
- package/src/components/ActionTable/Filters/FilterListToggle.vue +1 -13
- package/src/components/ActionTable/Filters/FilterToolbarLayout.vue +33 -0
- package/src/components/ActionTable/Filters/index.ts +1 -0
- package/src/components/ActionTable/index.ts +1 -1
- package/src/components/ActionTable/listActions.ts +19 -8
- package/src/components/ActionTable/tableColumns.ts +1 -1
- package/src/components/Utility/ImagePreview.vue +13 -10
- package/src/components/Utility/index.ts +2 -0
- package/src/config/index.ts +14 -0
- package/src/helpers/FileUpload.ts +8 -6
- package/src/helpers/singleFileUpload.ts +1 -1
- package/src/vue-plugin.js +2 -4
package/package.json
CHANGED
@@ -77,9 +77,9 @@
|
|
77
77
|
|
78
78
|
<script setup>
|
79
79
|
import { ref } from 'vue';
|
80
|
-
import { EmptyTableState, registerStickyScrolling, RenderComponent, TableSummaryRow } from '.';
|
81
80
|
import { DragHandleIcon as RowResizeIcon } from '../../svg';
|
82
81
|
import { HandleDraggable } from '../DragAndDrop';
|
82
|
+
import { EmptyTableState, registerStickyScrolling, RenderComponent, TableSummaryRow } from './index';
|
83
83
|
|
84
84
|
defineEmits(['action', 'filter', 'update:quasar-pagination', 'update:selected-rows']);
|
85
85
|
defineProps({
|
@@ -31,20 +31,8 @@ const props = defineProps({
|
|
31
31
|
type: Object,
|
32
32
|
required: true
|
33
33
|
},
|
34
|
-
filterGroups: {
|
35
|
-
type: Array,
|
36
|
-
required: true
|
37
|
-
},
|
38
34
|
showFilters: Boolean
|
39
35
|
});
|
40
36
|
|
41
|
-
const
|
42
|
-
return props.filterGroups.reduce((acc, fg) => {
|
43
|
-
fg.fields.forEach(f => {
|
44
|
-
acc[f.name] = true;
|
45
|
-
});
|
46
|
-
return acc;
|
47
|
-
}, {});
|
48
|
-
});
|
49
|
-
const activeCount = computed(() => Object.keys(props.filter).filter(key => props.filter[key] !== undefined && filterNameDictionary.value[key]).length);
|
37
|
+
const activeCount = computed(() => Object.keys(props.filter).filter(key => props.filter[key] !== undefined).length);
|
50
38
|
</script>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="w-full flex justify-end items-center flex-nowrap border-b">
|
3
|
+
<FilterListToggle
|
4
|
+
:show-filters="showFilters"
|
5
|
+
:filter="filter"
|
6
|
+
class="border-r p-4 flex-shrink-0"
|
7
|
+
@update:show-filters="$emit('update:show-filters', $event)"
|
8
|
+
@update:filter="$emit('update:filter', $event)"
|
9
|
+
/>
|
10
|
+
|
11
|
+
<div class="flex-grow">
|
12
|
+
<slot />
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div v-if="$slots['right-side']" class="flex justify-end items-stretch flex-nowrap p-4">
|
16
|
+
<QSeparator vertical class="mx-4 h-10 self-center" />
|
17
|
+
|
18
|
+
<slot name="right-side" />
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</template>
|
22
|
+
<script setup>
|
23
|
+
import { FilterListToggle } from "quasar-ui-danx";
|
24
|
+
|
25
|
+
defineEmits(["update:show-filters", "update:filter"]);
|
26
|
+
defineProps({
|
27
|
+
filter: {
|
28
|
+
type: Object,
|
29
|
+
default: null
|
30
|
+
},
|
31
|
+
showFilters: Boolean
|
32
|
+
});
|
33
|
+
</script>
|
@@ -6,5 +6,5 @@ export * from "./tableColumns";
|
|
6
6
|
export { default as ActionTable } from "./ActionTable.vue";
|
7
7
|
export { default as BatchActionMenu } from "./BatchActionMenu.vue";
|
8
8
|
export { default as EmptyTableState } from "./EmptyTableState.vue";
|
9
|
-
export { default as RenderComponent } from "
|
9
|
+
export { default as RenderComponent } from "./RenderComponent.vue";
|
10
10
|
export { default as TableSummaryRow } from "./TableSummaryRow.vue";
|
@@ -16,9 +16,11 @@ export function useListActions(name, {
|
|
16
16
|
urlPattern = null,
|
17
17
|
filterDefaults = {}
|
18
18
|
}) {
|
19
|
+
let isInitialized = false;
|
19
20
|
const PAGE_SETTINGS_KEY = `${name}-pagination-settings`;
|
20
21
|
const pagedItems = ref(null);
|
21
22
|
const filter = ref({});
|
23
|
+
const globalFilter = ref({});
|
22
24
|
const showFilters = ref(getItem(`${name}-show-filters`, true));
|
23
25
|
const selectedRows = ref([]);
|
24
26
|
const isLoadingList = ref(false);
|
@@ -39,7 +41,7 @@ export function useListActions(name, {
|
|
39
41
|
const pager = computed(() => ({
|
40
42
|
perPage: quasarPagination.value.rowsPerPage,
|
41
43
|
page: quasarPagination.value.page,
|
42
|
-
filter: filter.value,
|
44
|
+
filter: { ...filter.value, ...globalFilter.value },
|
43
45
|
sort: columns ? mapSortBy(quasarPagination.value, columns) : undefined
|
44
46
|
}));
|
45
47
|
|
@@ -59,15 +61,17 @@ export function useListActions(name, {
|
|
59
61
|
}
|
60
62
|
|
61
63
|
async function loadList() {
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
if (isInitialized) {
|
65
|
+
isLoadingList.value = true;
|
66
|
+
setPagedItems(await listRoute(pager.value));
|
67
|
+
isLoadingList.value = false;
|
68
|
+
}
|
65
69
|
}
|
66
70
|
|
67
71
|
async function loadSummary() {
|
68
|
-
if (summaryRoute) {
|
72
|
+
if (summaryRoute && isInitialized) {
|
69
73
|
isLoadingSummary.value = true;
|
70
|
-
const summaryFilter = { id: null, ...filter.value };
|
74
|
+
const summaryFilter = { id: null, ...filter.value, ...globalFilter.value };
|
71
75
|
if (selectedRows.value.length) {
|
72
76
|
summaryFilter.id = selectedRows.value.map((row) => row.id);
|
73
77
|
}
|
@@ -146,7 +150,7 @@ export function useListActions(name, {
|
|
146
150
|
const newItems = await moreRoute({
|
147
151
|
page: index + 1,
|
148
152
|
perPage,
|
149
|
-
filter: filter.value
|
153
|
+
filter: { ...filter.value, ...globalFilter.value }
|
150
154
|
});
|
151
155
|
|
152
156
|
if (newItems && newItems.length > 0) {
|
@@ -169,6 +173,9 @@ export function useListActions(name, {
|
|
169
173
|
* Loads the filter and pagination settings from local storage.
|
170
174
|
*/
|
171
175
|
function loadSettings() {
|
176
|
+
// Only load settings when the class is fully initialized
|
177
|
+
if (!isInitialized) return;
|
178
|
+
|
172
179
|
const settings = getItem(PAGE_SETTINGS_KEY);
|
173
180
|
|
174
181
|
// Load the filter settings from local storage
|
@@ -324,12 +331,16 @@ export function useListActions(name, {
|
|
324
331
|
}
|
325
332
|
|
326
333
|
// Async load the settings for this Action List
|
327
|
-
setTimeout(
|
334
|
+
setTimeout(() => {
|
335
|
+
isInitialized = true;
|
336
|
+
loadSettings();
|
337
|
+
}, 1);
|
328
338
|
|
329
339
|
return {
|
330
340
|
// State
|
331
341
|
pagedItems,
|
332
342
|
filter,
|
343
|
+
globalFilter,
|
333
344
|
filterActiveCount,
|
334
345
|
showFilters,
|
335
346
|
summary,
|
@@ -11,7 +11,7 @@ export function useTableColumns(name, columns, options = { titleMinWidth: 120, t
|
|
11
11
|
const columnOrder = ref(getItem(COLUMN_ORDER_KEY) || []);
|
12
12
|
|
13
13
|
// Manages visible columns on the table
|
14
|
-
const hiddenColumnNames = ref(getItem(VISIBLE_COLUMNS_KEY,
|
14
|
+
const hiddenColumnNames = ref(getItem(VISIBLE_COLUMNS_KEY, []));
|
15
15
|
|
16
16
|
// Title columns will have their name appear on the first column of the table as part of the records' title
|
17
17
|
const titleColumnNames = ref(getItem(TITLE_COLUMNS_KEY, []));
|
@@ -23,21 +23,21 @@
|
|
23
23
|
<PlayIcon class="w-16" />
|
24
24
|
</button>
|
25
25
|
</div>
|
26
|
-
<div
|
27
|
-
v-if="isPdf && !thumbUrl"
|
28
|
-
class="flex items-center justify-center h-full"
|
29
|
-
>
|
30
|
-
<PdfIcon class="w-24" />
|
31
|
-
</div>
|
32
26
|
<q-img
|
33
|
-
v-
|
27
|
+
v-if="thumbUrl || isPreviewable"
|
34
28
|
fit="scale-down"
|
35
29
|
class="non-selectable max-h-full max-w-full h-full"
|
36
30
|
:src="(thumbUrl || previewUrl) + '#t=0.1'"
|
37
31
|
preload="auto"
|
38
32
|
data-testid="previewed-image"
|
39
|
-
data-dusk="previewed-image"
|
40
33
|
/>
|
34
|
+
<div
|
35
|
+
v-else
|
36
|
+
class="flex items-center justify-center h-full"
|
37
|
+
>
|
38
|
+
<PdfIcon v-if="isPdf" class="w-24" />
|
39
|
+
<TextFileIcon v-else class="w-24" />
|
40
|
+
</div>
|
41
41
|
</div>
|
42
42
|
<div
|
43
43
|
v-if="$slots['action-button']"
|
@@ -98,7 +98,7 @@
|
|
98
98
|
</template>
|
99
99
|
|
100
100
|
<script setup>
|
101
|
-
import { DownloadIcon, PlayIcon } from '@heroicons/vue/outline';
|
101
|
+
import { DocumentTextIcon as TextFileIcon, DownloadIcon, PlayIcon } from '@heroicons/vue/outline';
|
102
102
|
import { computed, ref } from 'vue';
|
103
103
|
import { FullScreenCarouselDialog } from '.';
|
104
104
|
import { download } from '../../helpers';
|
@@ -148,6 +148,7 @@ const computedImage = computed(() => {
|
|
148
148
|
const mimeType = computed(
|
149
149
|
() => computedImage.value.type || computedImage.value.mime
|
150
150
|
);
|
151
|
+
const isImage = computed(() => mimeType.value.match(/^image\//));
|
151
152
|
const isVideo = computed(() => mimeType.value.match(/^video\//));
|
152
153
|
const isPdf = computed(() => mimeType.value.match(/^application\/pdf/));
|
153
154
|
const previewUrl = computed(
|
@@ -156,7 +157,9 @@ const previewUrl = computed(
|
|
156
157
|
const thumbUrl = computed(() => {
|
157
158
|
return computedImage.value.transcodes?.thumb?.url;
|
158
159
|
});
|
159
|
-
|
160
|
+
const isPreviewable = computed(() => {
|
161
|
+
return !!thumbUrl.value || isVideo.value || isImage.value;
|
162
|
+
});
|
160
163
|
const isConfirmingRemove = ref(false);
|
161
164
|
function onRemove() {
|
162
165
|
if (!isConfirmingRemove.value) {
|
@@ -1,11 +1,13 @@
|
|
1
1
|
export { default as CollapsableSidebar } from "./CollapsableSidebar.vue";
|
2
2
|
export { default as ConfirmDialog } from "./Dialogs/ConfirmDialog.vue";
|
3
3
|
export { default as ContentDrawer } from "./ContentDrawer.vue";
|
4
|
+
export { default as FlatList } from "./FlatList.vue";
|
4
5
|
export { default as FullScreenCarouselDialog } from "./Dialogs/FullscreenCarouselDialog.vue";
|
5
6
|
export { default as FullScreenDialog } from "./Dialogs/FullScreenDialog.vue";
|
6
7
|
export { default as ImagePreview } from "./ImagePreview.vue";
|
7
8
|
export { default as InfoDialog } from "./Dialogs/InfoDialog.vue";
|
8
9
|
export { default as InputDialog } from "./Dialogs/InputDialog.vue";
|
9
10
|
export { default as ListTransition } from "./Transitions/ListTransition.vue";
|
11
|
+
export { default as RefreshButton } from "./RefreshButton.vue";
|
10
12
|
export { default as SlideTransition } from "./Transitions/SlideTransition.vue";
|
11
13
|
export { default as StaggeredListTransition } from "./Transitions/StaggeredListTransition.vue";
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { uid } from "quasar";
|
2
|
+
import { danxOptions } from "../config";
|
2
3
|
import { resolveFileLocation } from "./files";
|
3
4
|
import { FlashMessages } from "./FlashMessages";
|
4
5
|
|
@@ -15,13 +16,9 @@ export class FileUpload {
|
|
15
16
|
onProgressCb = null;
|
16
17
|
onCompleteCb = null;
|
17
18
|
onAllCompleteCb = null;
|
18
|
-
options: FileUploadOptions =
|
19
|
-
directory: "file-upload",
|
20
|
-
presignedUploadUrl: null,
|
21
|
-
uploadCompletedUrl: null
|
22
|
-
};
|
19
|
+
options: FileUploadOptions = null;
|
23
20
|
|
24
|
-
constructor(files, options: FileUploadOptions) {
|
21
|
+
constructor(files, options: FileUploadOptions = null) {
|
25
22
|
if (!Array.isArray(files) && !(files instanceof FileList)) {
|
26
23
|
files = [files];
|
27
24
|
}
|
@@ -33,9 +30,14 @@ export class FileUpload {
|
|
33
30
|
this.onAllCompleteCb = null;
|
34
31
|
|
35
32
|
this.options = {
|
33
|
+
...danxOptions.fileUpload,
|
36
34
|
...this.options,
|
37
35
|
...options
|
38
36
|
};
|
37
|
+
|
38
|
+
if (!this.options.presignedUploadUrl) {
|
39
|
+
throw new Error("Please configure the danxOptions: import { configure } from 'quasar-ui-danx';");
|
40
|
+
}
|
39
41
|
this.prepare();
|
40
42
|
}
|
41
43
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { computed, ref } from "vue";
|
2
2
|
import { FileUpload, FileUploadOptions } from "./FileUpload";
|
3
3
|
|
4
|
-
export function useSingleFileUpload(options: FileUploadOptions) {
|
4
|
+
export function useSingleFileUpload(options: FileUploadOptions = null) {
|
5
5
|
const uploadedFile = ref(null);
|
6
6
|
const onCompleteCb = ref(null);
|
7
7
|
const onFileChangeCb = ref(null);
|
package/src/vue-plugin.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
+
export * from './config';
|
1
2
|
export * from './helpers';
|
2
|
-
export * from './components
|
3
|
-
export * from './components/ActionTable';
|
4
|
-
export * from './components/Utility';
|
3
|
+
export * from './components';
|
5
4
|
export * from './svg';
|
6
|
-
// export * from './components';
|
7
5
|
|
8
6
|
import packageJson from '../package.json';
|
9
7
|
|