Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a continuous modal navigation flow for all page block #1465

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,12 @@ export default {

const route = { name: 'page.record', params: { recordID, pageID: page.pageID } }

if (this.options.eventDisplayOption === 'newTab') {
if (this.inModal) {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: page.pageID,
})
} else if (this.options.eventDisplayOption === 'newTab') {
window.open(this.$router.resolve(route).href)
} else if (this.options.eventDisplayOption === 'modal') {
this.$root.$emit('show-record-modal', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,12 @@ export default {

const route = { name: 'page.record', params: { recordID, pageID: page.pageID } }

if (this.options.displayOption === 'newTab') {
if (this.inModal) {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: page.pageID,
})
} else if (this.options.displayOption === 'newTab') {
window.open(this.$router.resolve(route).href)
} else if (this.options.displayOption === 'modal') {
this.$root.$emit('show-record-modal', {
Expand Down
6 changes: 5 additions & 1 deletion client/web/compose/src/components/PageBlocks/MetricBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ import { NoID, compose } from '@cortezaproject/corteza-js'
import { evaluatePrefilter } from 'corteza-webapp-compose/src/lib/record-filter'

export default {
i18nOptions: {
namespaces: 'block',
},

components: {
MetricItem,
},
Expand Down Expand Up @@ -194,7 +198,7 @@ export default {
const metricID = `${this.block.blockID}-${name.replace(/\s+/g, '-').toLowerCase()}-${moduleID}-${metricIndex}`

const block = new compose.PageBlockRecordList({
title: name,
title: name || this.$t('metric.metricDrillDown'),
blockID: `drillDown-${metricID}`,
options: {
moduleID,
Expand Down
37 changes: 35 additions & 2 deletions client/web/compose/src/components/PageBlocks/RecordListBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@

<b-dropdown-item
v-if="isEditRecordActionVisible(item.r)"
:to="{ name: options.rowEditUrl || 'page.record.edit', params: { pageID: recordPageID, recordID: item.r.recordID }, query: null }"
@click="handleEditRecordAction(item.r.recordID)"
>
<font-awesome-icon
:icon="['far', 'edit']"
Expand All @@ -508,7 +508,7 @@

<b-dropdown-item
v-if="isCloneRecordActionVisible"
:to="{ name: options.rowCreateUrl || 'page.record.create', params: { pageID: recordPageID, values: item.r.values }, query: null }"
@click="handleCloneRecordAction(item.r.recordID, item.r.values)"
>
<font-awesome-icon
:icon="['far', 'clone']"
Expand Down Expand Up @@ -1941,6 +1941,39 @@ export default {
})
}
},

handleEditRecordAction (recordID) {
if (this.inModal) {
this.$root.$emit('show-record-modal', {
recordID: recordID,
recordPageID: this.recordPageID,
edit: true,
})
} else {
this.$router.push({
name: this.options.rowCreateUrl || 'page.record.edit',
params: { pageID: this.recordPageID, recordID },
query: null,
})
}
},

handleCloneRecordAction (recordID, values) {
if (this.inModal) {
this.$root.$emit('show-record-modal', {
recordID: recordID,
recordPageID: this.recordPageID,
values,
edit: true,
})
} else {
this.$router.push({
name: this.options.rowCreateUrl || 'page.record.create',
params: { pageID: this.recordPageID, values },
query: null,
})
}
},
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion client/web/compose/src/components/PageBlocks/Wrap/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</b-button>

<b-button
v-if="block.options.magnifyOption"
v-if="block.options.magnifyOption || isBlockMagnified"
:title="isBlockMagnified ? '' : $t('general.label.magnify')"
variant="outline-light"
class="d-flex align-items-center text-secondary d-print-none border-0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</b-button>

<b-button
v-if="block.options.magnifyOption"
v-if="block.options.magnifyOption || isBlockMagnified"
:title="isBlockMagnified ? '' : $t('general.label.magnify')"
variant="outline-light"
class="d-flex align-items-center text-secondary d-print-none border-0"
Expand Down
1 change: 1 addition & 0 deletions client/web/compose/src/components/PageBlocks/Wrap/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default {
return [
this.block.options.magnifyOption,
this.block.options.showRefresh,
this.isBlockMagnified
].some(c => !!c)
},

Expand Down
5 changes: 4 additions & 1 deletion client/web/compose/src/components/Public/Record/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:record-i-d="recordID"
:values="values"
:ref-record="refRecord"
:edit="edit"
show-record-modal
@handle-record-redirect="loadRecord"
@on-modal-back="loadRecord"
Expand Down Expand Up @@ -74,6 +75,7 @@ export default {
page: undefined,
values: undefined,
refRecord: undefined,
edit: false,
}
},

Expand Down Expand Up @@ -131,10 +133,11 @@ export default {
clearModalPreviousPage: 'ui/clearModalPreviousPage',
}),

loadRecord ({ recordID, recordPageID, values, refRecord, pushModalPreviousPage = true }) {
loadRecord ({ recordID, recordPageID, values, refRecord, edit, pushModalPreviousPage = true }) {
this.recordID = recordID
this.values = values
this.refRecord = refRecord
this.edit = edit

this.loadModal({ recordID, recordPageID })

Expand Down
15 changes: 15 additions & 0 deletions client/web/compose/src/views/Public/Pages/Records/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ export default {
type: Boolean,
required: false,
},

edit: {
type: Boolean,
default: false,
},
},

data () {
Expand Down Expand Up @@ -320,6 +325,16 @@ export default {
}
},
},

edit: {
immediate: true,
handler (value) {
if (value) {
this.inEditing = true
this.inCreating = true
}
},
},
},

mounted () {
Expand Down
1 change: 1 addition & 0 deletions locale/en/corteza-webapp-compose/block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ iframe:
srcFieldLabel: Field (URL) from record to use for the iframe
srcLabel: URL to show in the iframe
metric:
metricDrillDown: Metric drill down
defaultMetricLabel: Unnamed metric
drillDown:
label: Drill down
Expand Down