Skip to content

Commit

Permalink
UI: hide external layers in edit node #200
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jan 20, 2015
1 parent 09bca30 commit aa21a22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 14 additions & 4 deletions nodeshot/ui/default/static/ui/nodeshot/js/models.js
Expand Up @@ -209,9 +209,19 @@
url: Ns.url('layers/'),
model: Ns.models.Layer,

// layers in which users can add new nodes
getOpen: function(){
return new Ns.collections.Layer(this.where({ new_nodes_allowed: true }));
/**
* layers shown in edit node
* only external layers are hidden
*/
getEditList: function () {
return this.whereCollection({ is_external: false });
},

/**
* like where but returns collection
*/
whereCollection: function (options) {
return new Ns.collections.Layer(this.where(options));
}
});

Expand All @@ -232,7 +242,7 @@
schema: {
// TODO: i18n
name: { type: 'Text', title: 'name', validators: ['required'], editorAttrs: { maxlength: 75 } },
layer: { type: 'Select', title: 'layer', validators: ['required'], options: function(callback){ callback(Ns.db.layers.getOpen()) } },
layer: { type: 'Select', title: 'layer', validators: ['required'], options: function(callback){ callback(Ns.db.layers.getEditList()) } },
geometry: { type: 'Hidden', title: 'geometry', validators: ['required'] },
address: { type: 'Text', title: 'address', editorAttrs: { maxlength: 150 } },
elev: { type: 'Number', title: 'elevation', validators: ['number'] },
Expand Down
3 changes: 3 additions & 0 deletions nodeshot/ui/default/tests.py
Expand Up @@ -714,9 +714,12 @@ def test_edit_node(self):
WebDriverWait(self.browser, 5).until(ajax_complete, 'Login timeout')
sleep(1)

# go to edit
self._hashchange('#nodes/pomezia/edit')
sleep(0.2)
self.assertEqual(len(self.browser.find_elements_by_css_selector('#node-data-js form')), 1)
self.assertNotIn('vienna', self.browser.execute_script('return $("#node-data-js form select[name=layer]").html()'))
# go back to node details
self.browser.find_element_by_css_selector('#node-data-js form .btn-default').click()
self.assertEqual(len(self.browser.find_elements_by_css_selector('#node-data-js form')), 0)
self.assertIn('nodes/pomezia', self.browser.current_url)
Expand Down

0 comments on commit aa21a22

Please sign in to comment.