Commit ef6f1263 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

DOC: added some documentation for edit mode

parent 58e8dabc
......@@ -582,7 +582,11 @@ var edit_mode = new function() {
/*
* Initialize the edit mode and create a state machine.
*/
this.init_edit_app = function() {
// Panel that stores the "Create new Property" and "Create new RecordType" buttons.
var new_buttons = $('.caosdb-f-edit-panel-new-button');
var app = new StateMachine({
transitions: [{
......@@ -593,7 +597,6 @@ var edit_mode = new function() {
name: "newEntity",
from: "initial",
to: "changed"
}, {
name: "startEdit",
from: "initial",
......@@ -620,6 +623,7 @@ var edit_mode = new function() {
to: 'final'
}],
});
// Show a button "+" to create a new property when filter results in empty list.
new_buttons.filter('.caosdb-f-hide-on-empty-input').parent().each(function(index) {
var button = $(this);
button.hide();
......@@ -635,16 +639,22 @@ var edit_mode = new function() {
}
});
});
// handler for new property button
// calls newEntity transition of state machine
new_buttons.filter('.new-property').click(() => {
edit_mode.create_new_entity("Property").then(entity => {
app.newEntity(entity);
}, edit_mode.handle_error);
});
// handler for new record type button
// calls newEntity transition of state machine
new_buttons.filter('.new-recordtype').click(() => {
edit_mode.create_new_entity("RecordType").then(entity => {
app.newEntity(entity);
}, edit_mode.handle_error);
});
// Define listeners for dropping record types or properties on existing entites.
var parent_drop_listener = function(e) {
e.preventDefault();
var entity = $(this).parent();
......@@ -657,6 +667,8 @@ var edit_mode = new function() {
app.startEdit(entity);
edit_mode.add_dropped_property(e, app.entity);
}
// Define the error handler for the state machine.
app.errorHandler = function(fn) {
try {
fn();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment