public/erd/erd.js in erd-0.6.4 vs public/erd/erd.js in erd-0.7.0

- old
+ new

@@ -17,14 +17,16 @@ this.handle_text_elem_click = this.handle_text_elem_click.bind(this); this.handle_remove_model_click = this.handle_remove_model_click.bind(this); this.handle_new_model_add_column_click = this.handle_new_model_add_column_click.bind(this); this.handle_open_migration_click = this.handle_open_migration_click.bind(this); this.handle_close_migration_click = this.handle_close_migration_click.bind(this); + this.handle_save_position_changes_click = this.handle_save_position_changes_click.bind(this); this.name = name; this.elem = elem; this.edges = edges; this.paper = Raphael(this.name, this.elem.data('svg_width'), this.elem.data('svg_height')); + this.position_changes = {}; this.setup_handlers(); const models = this.elem.find('.model'); this.models = {}; for (let model of models) { this.models[$(model).data('model_name')] = model; @@ -120,22 +122,25 @@ target.addClass('noclick'); const model_name = target.data('model_name'); const from = target.data('original_position'); const to = [target.css('left').replace(/px$/, ''), target.css('top').replace(/px$/, '')].join(); this.upsert_change('move', model_name, '', '', to); + this.position_changes[model_name] = to; this.connect_arrows(this.edges.filter(e=> (e.from === model_name) || (e.to === model_name))); + document.getElementById("save_position_changes").style.visibility = "visible"; } setup_click_handlers() { - $('div.model_name_text, span.column_name_text, span.column_type_text').on('click', this.handle_text_elem_click); + $('div.model_name_text.edit, span.column_name_text.edit, span.column_type_text.edit').on('click', this.handle_text_elem_click); $('div.model a.add_column').on('click', this.handle_add_column_click); $('div.model a.cancel').on('click', this.handle_cancel_click); $('div.model a.close').on('click', this.handle_remove_model_click); $('#new_model_add_column').on('click', this.handle_new_model_add_column_click); $('div.model a.cancel').on('click', this.handle_cancel_click); $('div#open_migration').on('click', this.handle_open_migration_click); $('div#close_migration').on('click', this.handle_close_migration_click); + $('#save_position_changes').on('click', this.handle_save_position_changes_click); } setup_submit_handlers() { $('form.rename_model_form').on('submit', this.handle_rename_model); $('form.rename_column_form').on('submit', this.handle_rename_column); @@ -163,10 +168,11 @@ change[name] = value; }); return change; }).toArray(); $('#changes_form').find('input[name=changes]').val(JSON.stringify(changes)); + $('#changes_form').find('input[name=position_changes]').val(JSON.stringify(this.position_changes)); } handle_add_column(ev) { ev.preventDefault(); const target = $(ev.target); @@ -356,9 +362,14 @@ } target.hide() .parent().hide() .prev('div').show(); + } + + handle_save_position_changes_click(ev) { + $('#changes_form').find('input[name=position_changes]').val(JSON.stringify(this.position_changes)); + $('#changes_form').submit(); } } $(function() { window.erd = new ERD('erd', $('#erd'), window.raw_edges);