Skip to content

Commit

Permalink
Finished UFO-B model editing, refactorings, fixes, release
Browse files Browse the repository at this point in the history
  • Loading branch information
roper79 committed Dec 26, 2018
1 parent c2465ab commit 70fc6d1
Show file tree
Hide file tree
Showing 18 changed files with 4,070 additions and 308 deletions.
4 changes: 0 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
- opravit mazani entit na serveru
- mazani grafiky entit
- UFO-B mazani elementu: pridat mazani grafiky

- refactor to https://www.primefaces.org/primereact
27 changes: 17 additions & 10 deletions app/db/ufob.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// @flow

import * as R from 'ramda';
import type { Id } from '../metamodel/general';
import type { Situation, EventB, Disposition, UfobModel } from '../metamodel/ufob';
import type { Situation, EventB, UfobModel } from '../metamodel/ufob';
import * as ufobMeta from '../metamodel/ufob';
import * as urls from "../urls";
import * as ufobModel from '../model/ufob';
Expand Down Expand Up @@ -53,17 +52,21 @@ export function updateEvent(updatedEvent: EventB): Promise<any> {
if (validity.errors) {
reject("Event update failed: " + validity.errors);
} else {
postData(urls.baseURL + urls.ufobEventUpdate, { event: JSON.stringify(updatedEvent)}).then(result =>
resolve(result)
), error => reject(error);
postData(urls.baseURL + urls.ufobEventUpdate, { event: JSON.stringify(updatedEvent)}).then(
result => resolve(result),
error => reject(error)
);
}
});
}

export function deleteEvent(ev_id: Id): Promise<any> {
return new Promise((resolve, reject) => {
ufobModel.deleteEvent(model, ev_id);
postData(urls.baseURL + urls.ufobEventDelete, { ev_id }).then(result => resolve(result)), error => reject(error);
postData(urls.baseURL + urls.ufobEventDelete, { ev_id }).then(
result => resolve(result),
error => reject(error)
);
});
}

Expand All @@ -87,16 +90,20 @@ export function updateSituation(updatedSituation: Situation): Promise<any> {
if (validity.errors) {
reject("Situation update failed: " + validity.errors);
} else {
postData(urls.baseURL + urls.ufobSituationUpdate, { situation: JSON.stringify(updatedSituation)}).then(result =>
resolve(result)
), error => reject(error);
postData(urls.baseURL + urls.ufobSituationUpdate, { situation: JSON.stringify(updatedSituation)}).then(
result => resolve(result),
error => reject(error)
);
}
});
}

export function deleteSituation(s_id: Id): Promise<any> {
return new Promise((resolve, reject) => {
ufobModel.deleteSituation(model, s_id);
postData(urls.baseURL + urls.ufobSituationDelete, { s_id }).then(result => resolve(result)), error => reject(error);
postData(urls.baseURL + urls.ufobSituationDelete, { s_id }).then(
result => resolve(result),
error => reject(error)
);
});
}
8 changes: 4 additions & 4 deletions app/view/networkToolbar/saveLayoutButton.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@flow

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Button } from 'react-bootstrap';
import * as panels from '../panels';

Expand All @@ -14,9 +13,10 @@ export class SaveLayout extends React.Component<Props> {

save = () => {
var graphics = this.props.network.getPositions();
this.props.db.saveGraphics(graphics).then(() => {
panels.displayInfo("Diagram layout saved.");
}, (error) => panels.displayError("Diagram layout saving failed: " + error));
this.props.db.saveGraphics(graphics).then(
() => panels.displayInfo("Diagram layout saved."),
error => panels.displayError("Diagram layout saving failed: " + error)
);
}

render() {
Expand Down
14 changes: 9 additions & 5 deletions app/view/ufoa/dialogs/entityDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ function commitEntity(nodes: any, e: UfoaEntity) {
panels.hideDialog();
panels.displayInfo("Entity saved.");
},
error => panels.displayError("Entity save failed: " + error));
error => panels.displayError("Entity save failed: " + error)
);
}

class UfoaNodeForm extends React.Component<Props, State> {
Expand All @@ -56,7 +57,7 @@ class UfoaNodeForm extends React.Component<Props, State> {
});
}

save = (event) => {
save = () => {
let ufoaEntityOriginal = this.props.ufoaEntity;
let ufoaEntityNew = this.state.ufoaEntity2;
let nodes: any = this.props.ufoaVisModel.nodes;
Expand All @@ -65,12 +66,15 @@ class UfoaNodeForm extends React.Component<Props, State> {
}
};

delete = (event) => {
let nodes: any = this.props.ufoaVisModel.nodes;
let e_id = this.props.ufoaEntity.e_id;
delete = () => {
const nodes: any = this.props.ufoaVisModel.nodes;
const edges: any = this.props.ufoaVisModel.edges;
const e_id = this.props.ufoaEntity.e_id;
ufoaDB.deleteEntity(e_id).then(
() => {
nodes.remove({ id: e_id });
const edges2remove = edges.get().filter(e => e.from === e_id || e.to === e_id);
edges.remove(edges2remove.map(e => e.id));
panels.hideDialog();
panels.displayInfo("Entity deleted.");
},
Expand Down
19 changes: 12 additions & 7 deletions app/view/ufob/dialogs/eventDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,18 @@ class EventForm extends React.Component<Props, State> {
};

delete = () => {
let nodes: any = this.props.ufobVisModel.nodes;
let ev_id = this.props.eventB.ev_id;
ufobDB.deleteEvent(ev_id).then(() => {
nodes.remove({ id: ev_id });
panels.hideDialog();
panels.displayInfo("Event deleted.");
}, (error) => panels.displayError("Event delete failed: " + error));
const nodes: any = this.props.ufobVisModel.nodes;
const edges: any = this.props.ufobVisModel.edges;
const ev_id = this.props.eventB.ev_id;
ufobDB.deleteEvent(ev_id).then(
() => {
nodes.remove({ id: ev_id });
const edges2remove = edges.get().filter(e => e.from === ev_id || e.to === ev_id);
edges.remove(edges2remove.map(e => e.id));
panels.hideDialog();
panels.displayInfo("Event deleted.");
},
error => panels.displayError("Event delete failed: " + error));
}

renderEventName() {
Expand Down
34 changes: 21 additions & 13 deletions app/view/ufob/dialogs/situationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ class SituationForm extends React.Component<Props, State> {
}

commitSituation = (nodes: any, s: Situation) => {
ufobDB.updateSituation(s).then(() => {
nodes.update({ id: s.s_id, label: s.s_name });
this.updateEdges();
panels.hideDialog();
panels.displayInfo("Situation saved.");
}, (error) => panels.displayError("Situation save failed: " + error));
ufobDB.updateSituation(s).then(
() => {
nodes.update({ id: s.s_id, label: s.s_name });
this.updateEdges();
panels.hideDialog();
panels.displayInfo("Situation saved.");
},
error => panels.displayError("Situation save failed: " + error)
);
}

setAttr = (attr: string, val: any) => {
Expand Down Expand Up @@ -89,13 +92,18 @@ class SituationForm extends React.Component<Props, State> {
};

delete = () => {
let nodes: any = this.props.ufobVisModel.nodes;
let s_id = this.props.situation.s_id;
ufobDB.deleteSituation(s_id).then(() => {
nodes.remove({ id: s_id });
panels.hideDialog();
panels.displayInfo("Situation deleted.");
}, (error) => panels.displayError("Situation delete failed: " + error));
const nodes: any = this.props.ufobVisModel.nodes;
const edges: any = this.props.ufobVisModel.edges;
const s_id = this.props.situation.s_id;
ufobDB.deleteSituation(s_id).then(
() => {
nodes.remove({ id: s_id });
const edges2remove = edges.get().filter(e => e.from === s_id || e.to === s_id);
edges.remove(edges2remove.map(e => e.id));
panels.hideDialog();
panels.displayInfo("Situation deleted.");
},
error => panels.displayError("Situation delete failed: " + error));
}

renderSituationName = () => {
Expand Down
4 changes: 2 additions & 2 deletions data/ufoa-graphics.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@
"y": -9355
},
"e68": {
"x": -249,
"y": -5105
"x": -225,
"y": -5091
},
"e69": {
"x": -3098,
Expand Down
5 changes: 0 additions & 5 deletions data/ufoa.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,6 @@
"e_id": "e120",
"e_type": "relator",
"e_name": "Follow-up"
},
{
"e_id": "e121",
"e_type": "kind",
"e_name": "xxx"
}
],
"generalisations": [
Expand Down
Loading

0 comments on commit 70fc6d1

Please sign in to comment.