From de61dc936e47a3270515cc245d58f87b18d850a3 Mon Sep 17 00:00:00 2001 From: Atanas Yonkov Date: Fri, 25 Nov 2022 10:06:52 +0200 Subject: [PATCH] Add option to magnify certain page blocks --- .../components/PageBlocks/Configurator.vue | 18 +++ .../src/components/PageBlocks/Wrap/Card.vue | 47 +++++--- .../src/components/PageBlocks/Wrap/Plain.vue | 43 +++++-- .../components/Public/Page/Block/Modal.vue | 107 ++++++++++++++++++ .../src/components/Public/Page/Grid.vue | 1 + client/web/compose/src/components/faIcons.js | 2 + .../compose/src/views/Admin/Pages/Builder.vue | 1 + .../compose/src/views/Public/Pages/View.vue | 7 ++ lib/js/src/compose/types/page-block/base.ts | 1 + .../types/page-block/calendar/page-block.ts | 4 + lib/js/src/compose/types/page-block/chart.ts | 4 + .../src/compose/types/page-block/comment.ts | 4 +- .../src/compose/types/page-block/content.ts | 4 +- lib/js/src/compose/types/page-block/file.ts | 4 +- lib/js/src/compose/types/page-block/iframe.ts | 4 +- .../compose/types/page-block/record-list.ts | 4 +- .../types/page-block/record-revisions.ts | 3 + lib/js/src/compose/types/page-block/report.ts | 3 + locale/en/corteza-webapp-compose/block.yaml | 6 + 19 files changed, 237 insertions(+), 30 deletions(-) create mode 100644 client/web/compose/src/components/Public/Page/Block/Modal.vue diff --git a/client/web/compose/src/components/PageBlocks/Configurator.vue b/client/web/compose/src/components/PageBlocks/Configurator.vue index 1b15b9701..3c4517ce7 100644 --- a/client/web/compose/src/components/PageBlocks/Configurator.vue +++ b/client/web/compose/src/components/PageBlocks/Configurator.vue @@ -113,6 +113,16 @@ + + + + @@ -172,6 +182,14 @@ export default { isNew () { return this.block.blockID === NoID }, + + magnifyOptions () { + return [ + { value: '', text: this.$t('general.magnifyOptions.disabled') }, + { value: 'modal', text: this.$t('general.magnifyOptions.modal') }, + { value: 'fullscreen', text: this.$t('general.magnifyOptions.fullscreen') }, + ] + }, }, methods: { diff --git a/client/web/compose/src/components/PageBlocks/Wrap/Card.vue b/client/web/compose/src/components/PageBlocks/Wrap/Card.vue index eab57bcd7..8ee87a272 100644 --- a/client/web/compose/src/components/PageBlocks/Wrap/Card.vue +++ b/client/web/compose/src/components/PageBlocks/Wrap/Card.vue @@ -1,25 +1,22 @@ + + diff --git a/client/web/compose/src/components/Public/Page/Grid.vue b/client/web/compose/src/components/Public/Page/Grid.vue index 9feab2c9e..e641df605 100644 --- a/client/web/compose/src/components/Public/Page/Grid.vue +++ b/client/web/compose/src/components/Public/Page/Grid.vue @@ -10,6 +10,7 @@ > diff --git a/client/web/compose/src/components/faIcons.js b/client/web/compose/src/components/faIcons.js index 7005115df..bd1e2e693 100644 --- a/client/web/compose/src/components/faIcons.js +++ b/client/web/compose/src/components/faIcons.js @@ -8,6 +8,7 @@ import { faDownload, faFileExport, faSearch, + faSearchPlus, faBars, faCloudDownloadAlt, faTimes, @@ -104,6 +105,7 @@ library.add( faEdit, faTrashAlt, faSearch, + faSearchPlus, faBars, faCloudDownloadAlt, faTimes, diff --git a/client/web/compose/src/views/Admin/Pages/Builder.vue b/client/web/compose/src/views/Admin/Pages/Builder.vue index 9bbc7c046..9e26d7fed 100644 --- a/client/web/compose/src/views/Admin/Pages/Builder.vue +++ b/client/web/compose/src/views/Admin/Pages/Builder.vue @@ -103,6 +103,7 @@ v-bind="{ ...$attrs, ...$props, page, block, boundingRect, blockIndex: index }" :record="record" :module="module" + class="p-2" /> diff --git a/client/web/compose/src/views/Public/Pages/View.vue b/client/web/compose/src/views/Public/Pages/View.vue index 30431405a..1f8e7e1ca 100644 --- a/client/web/compose/src/views/Public/Pages/View.vue +++ b/client/web/compose/src/views/Public/Pages/View.vue @@ -66,6 +66,11 @@ :namespace="namespace" /> + + @@ -74,6 +79,7 @@ import { mapActions } from 'vuex' import Grid from 'corteza-webapp-compose/src/components/Public/Page/Grid' import AttachmentModal from 'corteza-webapp-compose/src/components/Public/Page/Attachment/Modal' import RecordModal from 'corteza-webapp-compose/src/components/Public/Record/Modal' +import MagnificationModal from 'corteza-webapp-compose/src/components/Public/Page/Block/Modal' import PageTranslator from 'corteza-webapp-compose/src/components/Admin/Page/PageTranslator' import { compose, NoID } from '@cortezaproject/corteza-js' @@ -87,6 +93,7 @@ export default { AttachmentModal, RecordModal, PageTranslator, + MagnificationModal, }, props: { diff --git a/lib/js/src/compose/types/page-block/base.ts b/lib/js/src/compose/types/page-block/base.ts index b977e459e..3bc335a1c 100644 --- a/lib/js/src/compose/types/page-block/base.ts +++ b/lib/js/src/compose/types/page-block/base.ts @@ -28,6 +28,7 @@ export class PageBlock { kind = '' public options = {} + public style: PageBlockStyle = { variants: { headerText: 'dark', diff --git a/lib/js/src/compose/types/page-block/calendar/page-block.ts b/lib/js/src/compose/types/page-block/calendar/page-block.ts index 39a046bfd..9b906edb5 100644 --- a/lib/js/src/compose/types/page-block/calendar/page-block.ts +++ b/lib/js/src/compose/types/page-block/calendar/page-block.ts @@ -36,6 +36,7 @@ class CalendarOptions { public header: Partial = {} public locale = 'en-gb' public refreshRate = 0 + public magnifyOption = '' } /** @@ -58,6 +59,9 @@ export class PageBlockCalendar extends PageBlock { applyOptions (o?: Partial): void { if (!o) return Apply(this.options, o, Number, 'refreshRate') + + Apply(this.options, o, String, 'magnifyOption') + this.options.defaultView = PageBlockCalendar.handleLegacyView(o.defaultView) || 'dayGridMonth' this.options.feeds = (o.feeds || []).map(f => new Feed(f)) this.options.header = merge( diff --git a/lib/js/src/compose/types/page-block/chart.ts b/lib/js/src/compose/types/page-block/chart.ts index 6c826eaf9..0a6a2a331 100644 --- a/lib/js/src/compose/types/page-block/chart.ts +++ b/lib/js/src/compose/types/page-block/chart.ts @@ -6,11 +6,13 @@ const kind = 'Chart' interface Options { chartID: string; refreshRate: number; + magnifyOption: string } const defaults: Readonly = Object.freeze({ chartID: NoID, refreshRate: 0, + magnifyOption: '' }) export class PageBlockChart extends PageBlock { @@ -28,6 +30,8 @@ export class PageBlockChart extends PageBlock { Apply(this.options, o, CortezaID, 'chartID') Apply(this.options, o, Number, 'refreshRate') + Apply(this.options, o, String, 'magnifyOption') + } } diff --git a/lib/js/src/compose/types/page-block/comment.ts b/lib/js/src/compose/types/page-block/comment.ts index a8bd8e19b..5de61b8da 100644 --- a/lib/js/src/compose/types/page-block/comment.ts +++ b/lib/js/src/compose/types/page-block/comment.ts @@ -10,6 +10,7 @@ interface Options { referenceField: string; sortDirection: string; refreshRate: number; + magnifyOption: string } const defaults: Readonly = Object.freeze({ @@ -20,6 +21,7 @@ const defaults: Readonly = Object.freeze({ sortDirection: '', referenceField: '', refreshRate: 0, + magnifyOption: '' }) export class PageBlockComment extends PageBlock { @@ -35,7 +37,7 @@ export class PageBlockComment extends PageBlock { applyOptions (o?: Partial): void { if (!o) return Apply(this.options, o, CortezaID, 'moduleID') - Apply(this.options, o, String, 'titleField', 'contentField', 'referenceField', 'filter', 'sortDirection') + Apply(this.options, o, String, 'titleField', 'contentField', 'referenceField', 'filter', 'sortDirection', 'magnifyOption') Apply(this.options, o, Number, 'refreshRate') } } diff --git a/lib/js/src/compose/types/page-block/content.ts b/lib/js/src/compose/types/page-block/content.ts index 19017b1fa..83f2beec3 100644 --- a/lib/js/src/compose/types/page-block/content.ts +++ b/lib/js/src/compose/types/page-block/content.ts @@ -5,10 +5,12 @@ const kind = 'Content' interface Options { body: string; + magnifyOption: string } const defaults: Readonly = Object.freeze({ body: '', + magnifyOption: '' }) export class PageBlockContent extends PageBlock { @@ -24,7 +26,7 @@ export class PageBlockContent extends PageBlock { applyOptions (o?: Partial): void { if (!o) return - Apply(this.options, o, String, 'body') + Apply(this.options, o, String, 'body', 'magnifyOption') } } diff --git a/lib/js/src/compose/types/page-block/file.ts b/lib/js/src/compose/types/page-block/file.ts index ea7813fc2..9137608ba 100644 --- a/lib/js/src/compose/types/page-block/file.ts +++ b/lib/js/src/compose/types/page-block/file.ts @@ -14,6 +14,7 @@ interface Options { borderRadius?: number; margin?: number; backgroundColor?: string; + magnifyOption: string; } const PageBlockFileDefaultMode = 'list' @@ -39,6 +40,7 @@ const defaults: Readonly = Object.freeze({ borderRadius: undefined, margin: undefined, backgroundColor: undefined, + magnifyOption: '' }) export class PageBlockFile extends PageBlock { @@ -59,7 +61,7 @@ export class PageBlockFile extends PageBlock { } Apply(this.options, o, Boolean, 'hideFileName') - Apply(this.options, o, String, 'backgroundColor') + Apply(this.options, o, String, 'backgroundColor', 'magnifyOption') Apply(this.options, o, Number, 'height', 'width', 'maxHeight', 'maxWidth', 'borderRadius', 'margin') if (o.mode) { diff --git a/lib/js/src/compose/types/page-block/iframe.ts b/lib/js/src/compose/types/page-block/iframe.ts index 59837069a..179a6a2db 100644 --- a/lib/js/src/compose/types/page-block/iframe.ts +++ b/lib/js/src/compose/types/page-block/iframe.ts @@ -8,6 +8,7 @@ interface Options { src: string; wrap: PageBlockWrap; refreshRate: number; + magnifyOption: string; } const defaults: Readonly = Object.freeze({ @@ -15,6 +16,7 @@ const defaults: Readonly = Object.freeze({ src: '', wrap: 'Plain', refreshRate: 0, + magnifyOption: '', }) export class PageBlockIFrame extends PageBlock { @@ -30,7 +32,7 @@ export class PageBlockIFrame extends PageBlock { applyOptions (o?: Partial): void { if (!o) return - Apply(this.options, o, String, 'srcField', 'src', 'wrap') + Apply(this.options, o, String, 'srcField', 'src', 'wrap', 'magnifyOption') Apply(this.options, o, Number, 'refreshRate') } } diff --git a/lib/js/src/compose/types/page-block/record-list.ts b/lib/js/src/compose/types/page-block/record-list.ts index 06e09cba2..ffa1818dc 100644 --- a/lib/js/src/compose/types/page-block/record-list.ts +++ b/lib/js/src/compose/types/page-block/record-list.ts @@ -24,6 +24,7 @@ interface Options { allowExport: boolean; perPage: number; recordDisplayOption: string; + magnifyOption: string; fullPageNavigation: boolean; showTotalCount: boolean; @@ -70,6 +71,7 @@ const defaults: Readonly = Object.freeze({ allowExport: false, perPage: 20, recordDisplayOption: 'sameTab', + magnifyOption: '', fullPageNavigation: true, showTotalCount: true, @@ -105,7 +107,7 @@ export class PageBlockRecordList extends PageBlock { if (!o) return Apply(this.options, o, CortezaID, 'moduleID') - Apply(this.options, o, String, 'prefilter', 'presort', 'selectMode', 'positionField', 'refField') + Apply(this.options, o, String, 'prefilter', 'presort', 'selectMode', 'positionField', 'refField', 'recordDisplayOption', 'magnifyOption') Apply(this.options, o, Number, 'perPage', 'refreshRate') if (o.fields) { diff --git a/lib/js/src/compose/types/page-block/record-revisions.ts b/lib/js/src/compose/types/page-block/record-revisions.ts index 5ac2f825d..f7f3852d1 100644 --- a/lib/js/src/compose/types/page-block/record-revisions.ts +++ b/lib/js/src/compose/types/page-block/record-revisions.ts @@ -17,6 +17,7 @@ interface Options { // referenced fields (records, users) we want to expand expRefFields: string[]; refreshRate: number; + magnifyOption: string; } const defaults: Readonly = Object.freeze({ @@ -24,6 +25,7 @@ const defaults: Readonly = Object.freeze({ displayedFields: [], expRefFields: [], refreshRate: 0, + magnifyOption: '', }) export class PageBlockRecordRevisions extends PageBlock { @@ -41,6 +43,7 @@ export class PageBlockRecordRevisions extends PageBlock { Apply(this.options, o, Boolean, 'preload') Apply(this.options, o, Number, 'refreshRate') + Apply(this.options, o, String, 'magnifyOption') // set new values to displayed fields if (Array.isArray(o?.displayedFields)) { diff --git a/lib/js/src/compose/types/page-block/report.ts b/lib/js/src/compose/types/page-block/report.ts index 5c5e4744f..e28be4e90 100644 --- a/lib/js/src/compose/types/page-block/report.ts +++ b/lib/js/src/compose/types/page-block/report.ts @@ -8,6 +8,7 @@ interface Options { scenarioID: string; elementID: string; refreshRate: number; + magnifyOption: string; } const defaults: Readonly = Object.freeze({ @@ -15,6 +16,7 @@ const defaults: Readonly = Object.freeze({ scenarioID: NoID, elementID: NoID, refreshRate: 0, + magnifyOption: '' }) export class PageBlockReport extends PageBlock { @@ -32,6 +34,7 @@ export class PageBlockReport extends PageBlock { Apply(this.options, o, CortezaID, 'reportID', 'scenarioID', 'elementID') Apply(this.options, o, Number, 'refreshRate') + Apply(this.options, o, String, 'magnifyOption') } } diff --git a/locale/en/corteza-webapp-compose/block.yaml b/locale/en/corteza-webapp-compose/block.yaml index 1d29abaed..a1c70e86c 100644 --- a/locale/en/corteza-webapp-compose/block.yaml +++ b/locale/en/corteza-webapp-compose/block.yaml @@ -112,6 +112,11 @@ general: descriptionLabel: Description descriptionPlaceholder: Block description headerStyle: Block header style (color) + magnifyLabel: Block Magnification + magnifyOptions: + disabled: Disabled + modal: Modal + fullscreen: Fullscreen wrap: Display block as a card refresh: label: Block auto-refresh interval @@ -130,6 +135,7 @@ general: remove: Remove save: Save search: Search + magnify: Magnify Block module: Module style: danger: Danger variant