diff --git a/src/webapp/src/components/seatplan/editor/properties.vue b/src/webapp/src/components/seatplan/editor/properties.vue
index e69de29..2ee64ef 100644
--- a/src/webapp/src/components/seatplan/editor/properties.vue
+++ b/src/webapp/src/components/seatplan/editor/properties.vue
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/src/webapp/src/components/seatplan/editor/window.vue b/src/webapp/src/components/seatplan/editor/window.vue
index a62dadd..c782618 100644
--- a/src/webapp/src/components/seatplan/editor/window.vue
+++ b/src/webapp/src/components/seatplan/editor/window.vue
@@ -1,15 +1,28 @@
+
+
-
{ e.preventDefault(); print('context') }" @dblclick="enableEditMode( draggable.id )" class="draggable-box">
+ { e.preventDefault(); }" class="draggable-box">
This is a test example
-
+
+
+
+
+
@@ -24,33 +37,93 @@
},
data() {
return {
- draggables: { 1: { 'x': 100, 'y':100, 'h': 100, 'w': 100, 'active': false, 'draggable': true, 'resizable': true, 'id': 1 }, 2: { 'x': 100, 'y':100, 'h': 100, 'w': 100, 'active': false, 'draggable': true, 'resizable': true, 'id': 2 } }
+ active: 0,
+ draggables: { 1: { 'x': 100, 'y':100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': 1 }, 2: { 'x': 100, 'y':100, 'h': 100, 'w': 100, 'active': false, 'draggable': true, 'resizable': true, 'id': 2 } }
}
},
methods: {
- print(val) {
- console.log(val)
+ /*
+ Coords are from top left corner of box.
+ The below function is executed as the init hook (created hook)
+ of vue.js, so whenever this particular page is loaded.
+ It loads previous data (if available) and starts the event listeners
+ for keyevents (like delete) and also check if the user uses a desktop
+ browser that meets all the requirements for being able to use the editor
+ reliably according to testing done.
+ */
+ runHook () {
+ let self = this;
+
+ if ( sessionStorage.getItem( 'seatplan' ) ) {
+ this.draggables = JSON.parse( sessionStorage.getItem( 'seatplan' ) );
+ }
+
+ document.onkeydown = function ( event ) {
+ if ( event.key === 'Delete' ) {
+ event.preventDefault();
+ self.deleteSelected();
+ } else if ( event.ctrlKey && event.key === 's' ) {
+ event.preventDefault();
+ self.save();
+ }
+ };
},
- enableEditMode ( obj ) {
- this.draggables[ obj ].draggable = false;
- this.draggables[ obj ].resizable = false;
+ activateComponent ( id ) {
+ this.active = id;
},
- handleKeyboard ( key ) {
- console.log( key );
+ deactivateComponent () {
+ this.active = 0;
},
- disableEditMode () {
- for ( let draggable in this.draggables ) {
- this.draggables[ draggable ].draggable = true;
- this.draggables[ draggable ].resizable = true;
+ print ( val ) {
+ console.log( val );
+ },
+ saveHistory () {
+ let history = sessionStorage.getItem( 'seatplan-history' ) ? JSON.parse( sessionStorage.getItem( 'seatplan-history' ) ) : {};
+ let count = Object.keys( history ).length + 1;
+ if ( count - 1 > sessionStorage.getItem( 'historyPos' ) ) {
+ // remove all entries past historyPOS
+ }
+ sessionStorage.setItem( 'historyPos', count );
+ history[ count ] = this.draggables;
+ sessionStorage.setItem( 'seatplan-history', JSON.stringify( history ) );
+ this.save();
+ },
+ setOtherValues () {
+ this.draggables = { 1: { 'x': 100, 'y':100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': 1 }, 2: { 'x': 100, 'y':400, 'h': 200, 'w': 300, 'active': false, 'draggable': true, 'resizable': true, 'id': 2 } }
+ },
+ historyOp ( action ) {
+ if ( action === 'undo' ) {
+ if ( sessionStorage.getItem( 'historyPos' ) > 2 ) {
+ console.log( 'undo' );
+ sessionStorage.setItem( 'historyPos', parseInt( sessionStorage.getItem( 'historyPos' ) ) - 1 );
+ this.draggables = JSON.parse( sessionStorage.getItem( 'seatplan-history' ) )[ sessionStorage.getItem( 'historyPos' ) ];
+ }
+ } else if ( action === 'redo' ) {
+ if ( Object.keys( JSON.parse( sessionStorage.getItem( 'seatplan-history' ) ) ).length > sessionStorage.getItem( 'historyPos' ) ) {
+ console.log( 'redo' );
+ sessionStorage.setItem( 'historyPos', parseInt( sessionStorage.getItem( 'historyPos' ) ) + 1 );
+ this.draggables = JSON.parse( sessionStorage.getItem( 'seatplan-history' ) )[ sessionStorage.getItem( 'historyPos' ) ];
+ }
}
},
+ save () {
+ sessionStorage.setItem( 'seatplan', JSON.stringify( this.draggables ) );
+ },
+ deleteSelected () {
+ if ( confirm( 'Do you really want to delete the selected item?' ) ) {
+ console.log( 'deleting' );
+ }
+ }
+ },
+ created () {
+ this.runHook();
}
}