Skip to content

Commit

Permalink
Workaround strange bug with first time run.
Browse files Browse the repository at this point in the history
If there are no projects, the UI seems to not update the newly added
project correctly.  This has been worked around.  Ideally this should be
resolved in jigna.  Fixed an incorrect key-binding for saving the
project. Reduce the search text input size to fit better on smaller
screens.
  • Loading branch information
prabhuramachandran committed Feb 6, 2017
1 parent dc213db commit f514b1a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
6 changes: 3 additions & 3 deletions vixen/html/vixen_ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2 style="text-align:center; padding: 0px; margin: 0px;">
<section class='third' style="background:#ffe">
<h3>Available Projects</h3>
<ul>
<li v-for="project in vixen.projects" >
<li v-for="project in ui.vixen.projects" v-if="project.name != '__hidden__'">
{{project.name}}
<button v-on:click="busy_call(ui, 'view', project)">View</button>
<button v-on:click="busy_call(ui, 'edit', project)">Edit</button>
Expand Down Expand Up @@ -149,7 +149,7 @@ <h3 style="margin: 5px;"> View Project: {{viewer.name}}</h3>
<button v-on:click="busy_call(viewer, 'rescan')">Rescan</button>
<br>

<input v-model="viewer.search" style="width:75%" placeholder="Search"
<input v-model="viewer.search" style="width:60%" placeholder="Search"
v-on:keyup.enter="busy_call(viewer, 'do_search')">
<button v-on:click="busy_call(viewer, 'do_search')">Search</button>
<button v-on:click="viewer.clear_search()">Clear</button>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h3 style="margin: 5px;"> View Project: {{viewer.name}}</h3>
});

// Keybindings using Mousetrap
Mousetrap.bind(['command+s', 'control+s'], function(e) {
Mousetrap.bind(['command+s', 'ctrl+s'], function(e) {
jigna.models.ui.save();
return false;
});
Expand Down
8 changes: 4 additions & 4 deletions vixen/tests/test_vixen.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ def test_add_remove_project_works(self):
# Given
ui = VixenUI()
vixen = ui.vixen
self.assertEqual(len(vixen.projects), 0)
self.assertEqual(len(vixen.projects), 1)

# When
ui.add_project()

# Then
self.assertEqual(len(vixen.projects), 1)
p = vixen.projects[0]
self.assertEqual(len(vixen.projects), 2)
p = vixen.projects[-1]
self.assertEqual(p.name, 'Project1')
self.assertEqual(
vixen.save_file, os.path.join(self._temp, 'projects.json')
Expand All @@ -189,7 +189,7 @@ def test_add_remove_project_works(self):
ui.remove(p)

# Then
self.assertEqual(len(vixen.projects), 0)
self.assertEqual(len(vixen.projects), 1)

def test_search_string_updates_search_completed(self):
# Given
Expand Down
14 changes: 10 additions & 4 deletions vixen/vixen.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def load(self):
data = json.load(fp)
self.projects = [Project(name=x['name'], save_file=x['save_file'])
for x in data]
if len(self.projects) == 0:
# FIXME: This seems like a jigna issue. If the projects trait is an
# empty list to start with, then the UI does not seem to update
# correctly when a new project is added. Adding a hidden project
# seems to solve the issue. So this is a temporary workaround
# until a better fix is found.
self.projects = [Project(name='__hidden__')]

def remove(self, project):
if exists(project.save_file):
Expand Down Expand Up @@ -518,17 +525,16 @@ def remove(self, project):
self.editor.project = None

def add_project(self):
projects = self.vixen.projects
name = 'Project%d' % (len(projects) + 1)
name = 'Project%d' % (len(self.vixen.projects))
p = Project(name=name)
projects.append(p)
self.vixen.projects.append(p)
self.editor.project = p
logger.info('Added project %s', name)

def save(self):
with self.busy():
if self.mode == 'edit':
if self.editor and self.editor.project is not None:
if self.editor is not None and self.editor.project is not None:
self.editor.apply()
elif self.mode == 'view':
if self.viewer.project is not None:
Expand Down

0 comments on commit f514b1a

Please sign in to comment.