Skip to content

Commit 5e68c45

Browse files
author
Dennis Labordus
committed
Added plugin to save project with a new name.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent a8bb080 commit 5e68c45

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

public/js/plugins.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ export const officialPlugins = [
100100
requireDoc: true,
101101
position: 'top'
102102
},
103+
{
104+
name: 'Save project as...',
105+
src: '/src/menu/CompasSaveAs.js',
106+
icon: 'save',
107+
default: true,
108+
kind: 'menu',
109+
requireDoc: true,
110+
position: 'top'
111+
},
103112
{
104113
name: 'Validate using OCL',
105114
src: '/src/validators/CompasValidateSchema.js',

src/menu/CompasSaveAs.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {html, LitElement} from 'lit-element';
2+
import {get} from "lit-translate";
3+
4+
import {newPendingStateEvent, newWizardEvent, Wizard, WizardInputElement} from '../foundation.js';
5+
6+
import CompasSaveElement from "../compas/CompasSave.js";
7+
import {dispatchEventOnOpenScd} from "../compas/foundation.js";
8+
9+
import "../compas/CompasSave.js";
10+
11+
export default class CompasSaveMenuPlugin extends LitElement {
12+
doc!: XMLDocument;
13+
docName!: string;
14+
15+
private saveAsToCompasWizard(): Wizard {
16+
function saveToCompas() {
17+
return function (inputs: WizardInputElement[], wizard: Element) {
18+
const compasSave = <CompasSaveElement>wizard.shadowRoot!.querySelector('compas-save')
19+
if (!compasSave.valid()) {
20+
return [];
21+
}
22+
23+
dispatchEventOnOpenScd(newPendingStateEvent(compasSave.saveToCompas()));
24+
return [];
25+
};
26+
}
27+
28+
return [
29+
{
30+
title: get('compas.save.title'),
31+
primary: {
32+
icon: 'save',
33+
label: get('save'),
34+
action: saveToCompas(),
35+
},
36+
content: [
37+
html `<compas-save .doc="${this.doc}" .docName="${this.docName}">
38+
</compas-save>`
39+
],
40+
},
41+
];
42+
}
43+
44+
async run(): Promise<void> {
45+
this.dispatchEvent(newWizardEvent(this.saveAsToCompasWizard()));
46+
}
47+
}
48+
49+

0 commit comments

Comments
 (0)