quasar-ui-danx 0.0.18 → 0.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -49,27 +49,27 @@
49
49
  </template>
50
50
  <template #body-cell="rowProps">
51
51
  <q-td :key="rowProps.key" :props="rowProps">
52
- <template v-if="rowProps.col.component">
53
- <RenderComponentColumn
54
- :row-props="rowProps"
55
- @action="$emit('action', $event)"
56
- />
57
- </template>
58
- <template v-else-if="rowProps.col.fieldList">
59
- <div v-for="field in rowProps.col.fieldList" :key="field">
60
- {{ rowProps.row[field] }}
61
- </div>
62
- </template>
63
- <template v-else-if="rowProps.col.filterOnClick">
64
- <a @click="$emit('filter', rowProps.col.filterOnClick(rowProps.row))">
65
- {{ rowProps.value }}
66
- </a>
67
- </template>
68
- <template v-else>
69
- <slot v-bind="{name: rowProps.col.name, row: rowProps.row, value: rowProps.value}">
70
- {{ rowProps.value }}
71
- </slot>
72
- </template>
52
+ <component
53
+ :is="rowProps.col.onClick ? 'a' : 'div'"
54
+ @click="() => rowProps.col.onClick && rowProps.col.onClick(rowProps.row)"
55
+ >
56
+ <template v-if="rowProps.col.component">
57
+ <RenderComponent
58
+ :row-props="rowProps"
59
+ @action="$emit('action', $event)"
60
+ />
61
+ </template>
62
+ <template v-else-if="rowProps.col.fieldList">
63
+ <div v-for="field in rowProps.col.fieldList" :key="field">
64
+ {{ rowProps.row[field] }}
65
+ </div>
66
+ </template>
67
+ <template v-else>
68
+ <slot v-bind="{name: rowProps.col.name, row: rowProps.row, value: rowProps.value}">
69
+ {{ rowProps.value }}
70
+ </slot>
71
+ </template>
72
+ </component>
73
73
  </q-td>
74
74
  </template>
75
75
  </q-table>
@@ -77,9 +77,9 @@
77
77
 
78
78
  <script setup>
79
79
  import { ref } from 'vue';
80
- import { EmptyTableState, registerStickyScrolling, RenderComponentColumn, 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({
@@ -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 RenderComponentColumn } from "./RenderComponentColumn.vue";
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
- isLoadingList.value = true;
63
- setPagedItems(await listRoute(pager.value));
64
- isLoadingList.value = false;
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(loadSettings, 1);
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, columns.filter(c => c.category !== "General" || c.name === "status").map(c => c.name)));
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, []));
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <ul>
3
+ <li v-for="item in items" :key="item[column]">
4
+ {{ item[column] }}
5
+ </li>
6
+ </ul>
7
+ </template>
8
+ <script setup>
9
+ defineProps({
10
+ items: {
11
+ type: Array,
12
+ required: true
13
+ },
14
+ column: {
15
+ type: String,
16
+ required: true
17
+ }
18
+ });
19
+ </script>
@@ -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-else
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) {
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <QBtn
3
+ class="bg-neutral-plus-6"
4
+ :loading="loading"
5
+ >
6
+ <RefreshIcon class="w-5" />
7
+ </QBtn>
8
+ </template>
9
+ <script setup>
10
+ import { RefreshIcon } from "@heroicons/vue/solid";
11
+
12
+ defineEmits(["refresh"]);
13
+ defineProps({
14
+ loading: Boolean
15
+ });
16
+ </script>
@@ -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";
@@ -0,0 +1,14 @@
1
+ export let danxOptions = {
2
+ fileUpload: {
3
+ directory: "file-upload",
4
+ presignedUploadUrl: null,
5
+ uploadCompletedUrl: null
6
+ }
7
+ };
8
+
9
+ export function configure(options) {
10
+ danxOptions = {
11
+ ...danxOptions,
12
+ ...options
13
+ };
14
+ }
@@ -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/DragAndDrop';
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