Changeset 14be6af in osmose-frontend


Ignore:
Timestamp:
Mar 18, 2014 10:08:57 PM (6 years ago)
Author:
Frédéric Rodrigo <fred.rodrigo@…>
Branches:
master
Children:
00735d7
Parents:
ae49110
git-author:
Frédéric Rodrigo <fred.rodrigo@…> (05/03/2014 23:24:35)
git-committer:
Frédéric Rodrigo <fred.rodrigo@…> (18/03/2014 22:08:57)
Message:

Osmose Editor

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • static/map/Osmose.Editor.css

    rae49110 r14be6af  
    6969} 
    7070 
    71 #editor_save_form label { 
     71#editor_save_form br + label, #editor_save_form form + label { 
    7272  display: inline-block; 
    7373  text-align: right; 
  • static/map/Osmose.Editor.js

    rae49110 r14be6af  
    88  includes: L.Mixin.Events, 
    99 
    10   _editedObjectStack: {}, 
    11  
    12   _deletedObjectStack: {}, 
     10  _modifiyObjectStack: {}, 
     11 
     12  _deleteObjectStack: {}, 
    1313 
    1414  initialize: function (placeholder, options) { 
     
    2424 
    2525  edit: function (error, type, id) { 
    26     var self = this; 
    27     self._$container.html("<center><img src='../images/throbbler.gif' alt='downloading'></center>"); 
    28     self.show(); 
     26    this.show(); 
     27    if (this._$container.data().user != "True") { 
     28      return; 
     29    } 
     30 
     31    this._$container.html("<center><img src='../images/throbbler.gif' alt='downloading'></center>"); 
     32    var self = this; 
    2933    $.ajax({ 
    3034      url: '../api/0.2/error/' + error + '/fresh_elems', 
     
    5054      }); 
    5155      $('form .tags[data-type="' + type + '"][data-id="' + id + '"] input[type="text"]:last', self._$container).focus(); 
     56    }).fail(function (xhr, err) { 
     57      self._$container.html("readyState: " + xhr.readyState + "\nstatus: " + xhr.status); 
    5258    }); 
    5359  }, 
     
    5763      dialog = $('#dialog_editor_save_popup'); 
    5864 
    59     dialog.find('#editor-edited-count').text(Object.keys(this._editedObjectStack).length); 
    60     dialog.find('#editor-deleted-count').text(Object.keys(this._deletedObjectStack).length); 
     65    dialog.find('#editor-modify-count').text(Object.keys(this._modifiyObjectStack).length); 
     66    dialog.find('#editor-delete-count').text(Object.keys(this._deleteObjectStack).length); 
    6167 
    6268    dialog.dialog({ 
     
    7682            contentType: 'application/json', 
    7783            data: JSON.stringify({ 
    78               comment: document.forms.editor_save_form.elements.comment.value, 
    79               source: document.forms.editor_save_form.elements.source.value, 
    80               type: document.forms.editor_save_form.elements.type.value, 
    81               edited: self._editedObjectStack, 
    82               deleted: self._deletedObjectStack 
     84              tag: { 
     85                  comment: document.forms.editor_save_form.elements.comment.value, 
     86                  source: document.forms.editor_save_form.elements.source.value, 
     87                  type: document.forms.editor_save_form.elements.type.value 
     88              }, 
     89              reuse_changeset: document.forms.editor_save_form.elements.reuse_changeset.checked, 
     90              modify: self._modifiyObjectStack, 
     91              delete: self._deleteObjectStack 
    8392            }), 
    8493          }).done(function () { 
    85             self._editedObjectStack = {}; 
    86             self._deletedObjectStack = {}; 
     94            self._modifiyObjectStack = {}; 
     95            self._deleteObjectStack = {}; 
    8796            self._count_touched(); 
    8897            $(t).dialog('close'); 
     
    103112    $.each(this._extractData(), function (i, e) { 
    104113      if (e.touched) { 
    105         self._editedObjectStack[i] = e; 
    106         delete self._editedObjectStack[i]['touched']; 
     114        self._modifiyObjectStack[i] = e; 
     115        delete self._modifiyObjectStack[i]['touched']; 
    107116      } 
    108117    }); 
     
    112121 
    113122  _count_touched: function () { 
    114     var n = Object.keys(this._editedObjectStack).length + Object.keys(this._deletedObjectStack).length, 
     123    var n = Object.keys(this._modifiyObjectStack).length + Object.keys(this._deleteObjectStack).length, 
    115124      es = $("#menu-editor-save"); 
    116125    if (n > 0) { 
    117126      es.show(); 
    118       es.find("#menu-editor-save-number").text(Object.keys(this._editedObjectStack).length); 
     127      es.find("#menu-editor-save-number").text(Object.keys(this._modifiyObjectStack).length); 
    119128    } else { 
    120129      es.hide(); 
     
    138147        version: eee.dataset.version, 
    139148        touched: eee.dataset.touched == "true", 
    140         tags: elem 
     149        tag: elem 
    141150      }; 
    142151    }); 
     
    160169 
    161170    var tags = $(e.target).closest(".tags"); 
    162     this._build(tags.data('type'), tags.data('id'), tags.data('reftags'), this._extractData()[tags.data('type') + tags.data('id')].tags); 
     171    this._build(tags.data('type'), tags.data('id'), tags.data('reftags'), this._extractData()[tags.data('type') + tags.data('id')].tag); 
    163172  }, 
    164173 
     
    170179    del.empty(); 
    171180    $.each(reftags, function (e) { 
    172       if (!data[e]) { 
     181      if (data[e] == undefined) { 
    173182        var value = $('<div/>').text(e + '=' + reftags[e]).html(), 
    174183          key = $('<div/>').text(e).html(); 
     
    181190    same.empty(); 
    182191    $.each(reftags, function (e) { 
    183       if (data[e] && data[e] == reftags[e]) { 
     192      if (data[e] != undefined && data[e] == reftags[e]) { 
    184193        var value = $('<div/>').text(e + '=' + reftags[e]).html(), 
    185194          key = $('<div/>').text(e).html(); 
     
    191200    mod.empty(); 
    192201    $.each(reftags, function (e) { 
    193       if (data[e] && data[e] != reftags[e]) { 
     202      if (data[e] != undefined && data[e] != reftags[e]) { 
    194203        var value = $('<div/>').text(e + '=' + data[e]).html(), 
    195204          key = $('<div/>').text(e).html(), 
     
    203212    add.empty(); 
    204213    $.each(data, function (e) { 
    205       if (!reftags[e]) { 
     214      if (reftags[e] == undefined) { 
    206215        var value = $('<div/>').text(e + '=' + data[e]).html(), 
    207216          key = $('<div/>').text(e).html(); 
  • views/map/index.tpl

    rae49110 r14be6af  
    181181</script> 
    182182 
    183 <div id="editor"></div> 
     183<div id="editor" data-user="{{not not user}}"><p>{{_("You must be logged in order to use the tag editor")}}</p><a href="../login">{{_("Login")}}</a></div> 
    184184 
    185185<div id="dialog_editor_save_popup" title="{{_("Save changeset")}}" data-button_cancel="{{_("Cancel")}}" data-button_save="{{_("Save")}}" style="display:none"> 
    186   <p>{{_("Objects edited:")}}&nbsp;<span id="editor-edited-count"></span></p> 
    187   <p>{{_("Objects deleted:")}}&nbsp;<span id="editor-deleted-count"></span></p> 
     186  <p>{{_("Objects edited:")}}&nbsp;<span id="editor-modify-count"></span></p> 
     187  <p>{{_("Objects deleted:")}}&nbsp;<span id="editor-delete-count"></span></p> 
    188188  <form id="editor_save_form"> 
    189     <label for="comment">{{_("Comment")}}</label><input type="text" name="comment" id="comment" value="{{_("Fix with Osmose")}}"> 
     189    <label for="comment">{{_("Comment")}}</label><input type="text" name="comment" id="comment" value="{{_("Fix with Osmose")}}"/> 
    190190    <br/><br/> 
    191     <label for="source">{{_("Source")}}</label><input type="text" name="source" id="source" value="Osmose"> 
     191    <label for="source">{{_("Source")}}</label><input type="text" name="source" id="source" value="Osmose"/> 
    192192    <br/><br/> 
    193     <label for="type">{{_("Type")}}</label><input type="text" name="type" id="type" value="fix"> 
     193    <label for="type">{{_("Type")}}</label><input type="text" name="type" id="type" value="fix"/> 
     194    <br/><br/> 
     195    <input type="checkbox" name="reuse_changeset" id="reuse_changeset" checked="checked"/><label for="reuse_changeset">{{_("Reuse changeset")}}</label> 
    194196  </form> 
    195197</div> 
Note: See TracChangeset for help on using the changeset viewer.