cartodb/lib/assets/javascripts/new-dashboard/core/dialog-actions.js

227 lines
6.2 KiB
JavaScript
Raw Normal View History

2020-06-15 10:58:47 +08:00
// Dialogs
import Dialog from 'new-dashboard/components/Backbone/Dialog.vue';
import CreateDialog from 'new-dashboard/components/Backbone/Dialogs/CreateDialog';
import ChangePrivacy from 'new-dashboard/components/Backbone/Dialogs/ChangePrivacy';
import DeleteDialog from 'new-dashboard/components/Backbone/Dialogs/DeleteDialog';
import DuplicateMap from 'new-dashboard/components/Backbone/Dialogs/DuplicateMap';
import LockVisualization from 'new-dashboard/components/Backbone/Dialogs/LockVisualization';
import MapMetadata from 'new-dashboard/components/Backbone/Dialogs/MapMetadata';
import DatasetMetadata from 'new-dashboard/components/Backbone/Dialogs/DatasetMetadata';
import Share from 'new-dashboard/components/Backbone/Dialogs/Share';
export function editMapMetadata (visualization, actionHandlers) {
this.showModal(
{
template: `
<Dialog v-on:close="$emit('close')">
<MapMetadata
:visualization="visualization"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['visualization'],
components: { Dialog, MapMetadata },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
},
{ visualization }
);
}
export function editDatasetMetadata (dataset, actionHandlers) {
this.showModal(
{
template: `
<Dialog v-on:close="$emit('close')">
<DatasetMetadata
:dataset="dataset"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['dataset'],
components: { Dialog, DatasetMetadata },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
},
{ dataset }
);
}
export function createMap (selectedDatasets, backgroundPollingView, mamufasImportView) {
this.showModal(
{
template: `
<Dialog @close="$emit('close')">
<CreateDialog :selectedItems="selectedItems" :backgroundPollingView="backgroundPollingView" :mamufasImportView="mamufasImportView" @close="$emit('close')"/>
</Dialog>`,
props: ['selectedItems', 'backgroundPollingView', 'mamufasImportView'],
components: { Dialog, CreateDialog }
},
{
selectedItems: selectedDatasets,
backgroundPollingView,
mamufasImportView
}
);
}
export function changePrivacy (visualization, actionHandlers) {
this.showModal(
{
template: `
<Dialog @close="$emit('close')">
<ChangePrivacy
:visualization="visualization"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['visualization'],
components: { Dialog, ChangePrivacy },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
},
{ visualization }
);
}
export function shareVisualization (visualization, actionHandlers) {
this.showModal(
{
template: `
<Dialog v-on:close="$emit('close')">
<Share
:visualization="visualization"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['visualization'],
components: { Dialog, Share },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
},
{ visualization }
);
}
export function duplicateVisualization (visualization) {
this.showModal(
{
template: `
<Dialog @close="$emit('close')">
<DuplicateMap :visualization="visualization" @close="$emit('close')"/>
</Dialog>`,
props: ['visualization'],
components: { Dialog, DuplicateMap }
},
{ visualization }
);
}
export function changeLockState (visualization, contentType, actionHandlers) {
const dialogProps = { visualization, contentType };
this.showModal(
{
template: `
<Dialog @close="$emit('close')">
<LockVisualization
:visualization="visualization"
:contentType="contentType"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['visualization', 'contentType'],
components: { Dialog, LockVisualization },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
}, dialogProps
);
}
export function changeVisualizationsLockState (visualizations, contentType, actionHandlers) {
const dialogProps = { visualizations, contentType };
this.showModal(
{
template: `
<Dialog @close="$emit('close')">
<LockVisualization
:visualizations="visualizations"
:contentType="contentType"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['visualizations', 'contentType'],
components: { Dialog, LockVisualization },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
}, dialogProps
);
}
export function deleteVisualization (visualization, contentType, actionHandlers) {
const dialogProps = { visualization, contentType };
this.showModal(
{
template: `
<Dialog @close="$emit('close')">
<DeleteDialog
:visualization="visualization"
:contentType="contentType"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['visualization', 'contentType'],
components: { Dialog, DeleteDialog },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
}, dialogProps
);
}
export function deleteVisualizations (visualizations, contentType, actionHandlers) {
const dialogProps = { visualizations, contentType };
this.showModal(
{
template: `
<Dialog @close="$emit('close')">
<DeleteDialog
:visualizations="visualizations"
:contentType="contentType"
@close="$emit('close')"
v-on="getEventListeners()" />
</Dialog>`,
props: ['visualizations', 'contentType'],
components: { Dialog, DeleteDialog },
methods: {
getEventListeners: function () {
return actionHandlers || {};
}
}
}, dialogProps
);
}