Skip to content

Commit

Permalink
Merge pull request #9 from vixen-project/ui-fixes
Browse files Browse the repository at this point in the history
Ui fixes
  • Loading branch information
prabhuramachandran committed Jan 14, 2018
2 parents 5b21257 + e87ee7c commit ff60fc5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
16 changes: 10 additions & 6 deletions vixen/html/vixen_ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ <h3> Edit Project</h3>
<option>float</option>
<option>bool</option>
</select>
<button v-on:click="editor.move_tag_up(parseInt(index))"
v-bind:id="'move-tag-up' + index">&uarr;</button>
<button v-on:click="editor.move_tag_down(parseInt(index))"
v-bind:id="'move-tag-down' + index">&darr;</button>
<button v-on:click="editor.remove_tag(parseInt(index))"
v-bind:id="'remove-tag-' + index">Remove</button>
</div>
<input v-model="editor.tag_name"
title="Enter a new tag. You may separate multiple tags by commas."
id="new-tag">
id="new-tag" lazy>
<button v-on:click="editor.add_tag(editor.tag_name)" id="add-tag">
Add tag
</button>
Expand All @@ -113,7 +117,7 @@ <h3> Edit Project</h3>
</li>
</ul>
<input v-model="editor.ext_name" id="new-extension"
title="Case is not significant, use commas for multiple extensions. Examples: '.jpg' or '.jpg, .png'.">
title="Case is not significant, use commas for multiple extensions. Examples: '.jpg' or '.jpg, .png'." lazy>
<button v-on:click="editor.add_extension(editor.ext_name)" id="add-extension">
Add extension
</button>
Expand Down Expand Up @@ -157,7 +161,7 @@ <h3 style="margin: 5px;"> View Project: {{viewer.name}}</h3>
<br>

<input v-model="viewer.search" style="width:60%" placeholder="Search"
v-on:keyup.enter="busy_call(viewer, 'do_search')" id="search-text">
v-on:keyup.enter="busy_call(viewer, 'do_search')" id="search-text" lazy>
<button v-on:click="busy_call(viewer, 'do_search')" id="search">Search</button>
<button v-on:click="viewer.clear_search()" id="clear-search">Clear</button>

Expand Down Expand Up @@ -289,9 +293,9 @@ <h3 style="margin: 5px;"> View Project: {{viewer.name}}</h3>
<input v-if="tag.type == 'bool'" v-model="media.tags[tag.name]"
type="checkbox" v-bind:id="'tag-' + $index">
<input v-if="tag.type == 'string'"
v-model="media.tags[tag.name]" v-bind:id="'tag-' + $index">
v-model="media.tags[tag.name]" v-bind:id="'tag-' + $index" lazy>
<input v-if="tag.type == 'int' || tag.type == 'float'"
v-model="media.tags[tag.name]" number v-bind:id="'tag-' + $index">
v-model="media.tags[tag.name]" number v-bind:id="'tag-' + $index" lazy>
</div>
</div>
</script>
Expand Down Expand Up @@ -383,7 +387,7 @@ <h3 style="margin: 5px;"> View Project: {{viewer.name}}</h3>
<br/>
<label>Command:</label>
<input v-model="proc.command"
title="Use $input for input file and $output for output file">
title="Use $input for input file and $output for output file" lazy>
<br/>
</div>

Expand Down
37 changes: 37 additions & 0 deletions vixen/tests/test_vixen.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,43 @@ def test_add_remove_tag(self):
self.assertEqual(editor.tags[-1].name, 'tag2')
self.assertEqual(editor.tags[-2].name, 'completed')

def test_move_tag(self):
# Given
ui = self.ui
editor = ui.editor

def _get_tags():
return [x.name for x in editor.tags]

ui.edit(self.p)
editor.add_tag('tag1, tag2')
assert _get_tags() == ['completed', 'tag1', 'tag2']

# When
editor.move_tag_up(0)
# Then
assert _get_tags() == ['completed', 'tag1', 'tag2']
# When
editor.move_tag_up(1)
# Then
assert _get_tags() == ['tag1', 'completed', 'tag2']
# When
editor.move_tag_up(2)
# Then
assert _get_tags() == ['tag1', 'tag2', 'completed']
# When
editor.move_tag_down(2)
# Then
assert _get_tags() == ['tag1', 'tag2', 'completed']
# When
editor.move_tag_down(1)
# Then
assert _get_tags() == ['tag1', 'completed', 'tag2']
# When
editor.move_tag_down(0)
# Then
assert _get_tags() == ['completed', 'tag1', 'tag2']

def test_add_remove_extension(self):
# Given
ui = self.ui
Expand Down
12 changes: 12 additions & 0 deletions vixen/vixen.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ def remove_tag(self, index):
logger.info('Removed tag: %s', self.tags[index].name)
del self.tags[index]

def move_tag_up(self, index):
if index != 0:
tags = self.tags
logger.info('Moving up tag: %s', tags[index].name)
tags[index - 1:index + 1] = tags[index], tags[index-1]

def move_tag_down(self, index):
tags = self.tags
if index != len(tags) - 1:
logger.info('Moving down tag: %s', tags[index].name)
tags[index:index + 2] = tags[index + 1], tags[index]

def add_extension(self, name):
logger.info('Added extensions: %s', name)
self.extensions.extend([x.strip().lower() for x in name.split(',')])
Expand Down

0 comments on commit ff60fc5

Please sign in to comment.