-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace application list view with a Vue ViewModel #402
Conversation
// This model keeps the retrieved content from the REST query locally. | ||
// It is only synchronized at initial load. | ||
var model = new models.ApplicationListModel(); | ||
var app_list_view = new application_list_view.ApplicationListView(model); | ||
var app_list_view = application_list_view.applicationListView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use underscores.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also assign the model at this stage.
We initialize this element with "display: none" to prevent displaying | ||
"No applications found" and the loading spinner at the same time | ||
--> | ||
<li v-show="!loading && model.app_list.length === 0" style="display: none;"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use a v-else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no gain to use v-if
and v-else
instead of two v-show
in terms of lines of code. And my problem is that it changes the behavior of the dom elements, v-if
will result in rendering the element only if the statement is true, v-show
only changes the style attribute display
of the element, so I have to change the selenium tests which relies on the style attribute
remoteappmanager/templates/home.html
Outdated
--> | ||
<li v-for="(app, index) in model.app_list" | ||
v-bind:class="{ active: index === model.selected_index }" | ||
v-on:click="model.selected_index = index" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v-on -> @click
remoteappmanager/templates/home.html
Outdated
issues when the javascript is not loaded yet (temporary ?) | ||
--> | ||
<li v-for="(app, index) in model.app_list" | ||
v-bind:class="{ active: index === model.selected_index }" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v-bind also has a shorthand. I think it's just :class
remoteappmanager/templates/home.html
Outdated
v-bind:src="get_icon_src(app.app_data)"> | ||
|
||
<button class="stop-button" | ||
v-show="app.status === 'RUNNING' && index_mouse_over === index" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to do this with simple CSS
stop_application: function(index) { | ||
this.stop_application_callback(index); | ||
}, | ||
mouse_enter: function(index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe as CSS?
this.index_mouse_over = index; | ||
} | ||
}, | ||
mouse_leave: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe with CSS?
if (self.model.selected_index === index) { | ||
self.update_selected(); | ||
watch: { | ||
'model.selected_index': function() { this.selected_app_callback(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will eventually go away when the syncronization is performed through the model
if (properties.length === 0) { | ||
fieldset.html("No configurable options for this image"); | ||
} else { | ||
properties.forEach( | ||
function(val) { // jshint ignore:line | ||
var widget = configurables[val].view(index); | ||
fieldset.append(widget); | ||
// Vue.js adds an __ob__ property, we have to fix it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you replace the properties with a list, it should cause no harm and solve this.
bower.json
Outdated
@@ -1,32 +1,33 @@ | |||
{ | |||
"name": "simphony-remote-deps", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use four spaces for indentation. I checked the preferred style guide, and most of the opinions are for four spaces, like in python, including Crockford. We don't have to save space, minification will do that (if ever, js files are cached anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, correction. Google uses two. uhm....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, keep two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, keep four for now, and we'll switch to two after this PR is in
bower.json
Outdated
@@ -1,32 +1,33 @@ | |||
{ | |||
"name": "simphony-remote-deps", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, keep four for now, and we'll switch to two after this PR is in
Codecov Report
@@ Coverage Diff @@
## switch_to_vue #402 +/- ##
==============================================
Coverage 95.17% 95.17%
==============================================
Files 94 94
Lines 3996 3996
Branches 256 256
==============================================
Hits 3803 3803
Misses 139 139
Partials 54 54 Continue to review full report at Codecov.
|
The gain of the last changes was null and it results in test failing. I prefer to undo those changes instead of changing the tests.
No description provided.