Skip to content
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

Merged
merged 36 commits into from
Apr 25, 2017

Conversation

martinRenou
Copy link
Member

No description provided.

// 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use underscores.

Copy link
Contributor

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;">
Copy link
Contributor

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.

Copy link
Member Author

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-ifwill result in rendering the element only if the statement is true, v-showonly changes the style attribute displayof the element, so I have to change the selenium tests which relies on the style attribute

-->
<li v-for="(app, index) in model.app_list"
v-bind:class="{ active: index === model.selected_index }"
v-on:click="model.selected_index = index"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v-on -> @click

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 }"
Copy link
Contributor

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

v-bind:src="get_icon_src(app.app_data)">

<button class="stop-button"
v-show="app.status === 'RUNNING' && index_mouse_over === index"
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor

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() {
Copy link
Contributor

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(); }
Copy link
Contributor

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
Copy link
Contributor

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",
Copy link
Contributor

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)

Copy link
Contributor

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....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, keep two.

Copy link
Contributor

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",
Copy link
Contributor

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-io
Copy link

codecov-io commented Apr 25, 2017

Codecov Report

Merging #402 into switch_to_vue will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@              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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c892b79...a8d6dfb. Read the comment docs.

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.
@martinRenou martinRenou merged commit 4e5c077 into switch_to_vue Apr 25, 2017
@martinRenou martinRenou changed the title Replace application list view with a Vue ViewModel [WIP] Replace application list view with a Vue ViewModel Apr 25, 2017
@martinRenou martinRenou deleted the replace_application_list2 branch April 25, 2017 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants