Skip to content

Commit

Permalink
VBV-1995 - Redesign the registry UI based on Option vmware-archive#2
Browse files Browse the repository at this point in the history
Layout enhancements.

Change-Id: If72c5e2289ade63f035a5c2b6e2e14a9a0607e39
Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/36295
Upgrade-Verified: jenkins <[email protected]>
Closures-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Reviewed-by: Iveta Ilieva <[email protected]>
  • Loading branch information
iilieva committed Jun 15, 2018
1 parent 225e623 commit b70baa4
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 100 deletions.
7 changes: 4 additions & 3 deletions ui/app/src/js/components/common/CommonComponentsRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
*/

/**
* Helper class that imports The common Vue components so they can be used without imports in other
* Vue components. Internally when components are imported for the first time they register as Vue
* components.
* Helper class that imports the common Vue components, so that they can be used without need for
* imports in other Vue components.
* Internally when components are imported for the first time they register as Vue components.
* */

/* eslint-disable */

import GridSearch from 'components/common/GridSearch';
import VueGridSearchTag from 'components/common/VueGridSearchTag';
import VueSearch from 'components/common/VueSearch';
import VueRefreshButton from 'components/common/VueRefreshButton';
import ListTitle from 'components/common/ListTitle';
Expand Down
81 changes: 1 addition & 80 deletions ui/app/src/js/components/common/GridSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,17 @@ var GridSearch = Vue.extend({
placeholder: {
type: String,
required: false
},
searchTagName: {
type: String,
required: false
},
searchTagOptions: {
type: Array,
required: false
}
},

computed: {
hasSearchTag() {
return this.searchTagName && this.searchTagOptions;
}
},

data: function() {
return {
searchString: '',
occurrenceSelection: constants.SEARCH_OCCURRENCE.ALL,
searchTagSelection: ''
occurrenceSelection: constants.SEARCH_OCCURRENCE.ALL
};
},

attached: function() {

this.unwatchQueryOptions = this.$watch('searchTagOptions', () => {
this.initSearchTagSelection();
}, { immediate: true });

this.unwatchQueryOptions = this.$watch('queryOptions', (newQueryOptions, oldQueryOptions) => {
if (!utils.equals(oldQueryOptions, newQueryOptions)) {
let oldSearchString = uiCommonLib.searchUtils.getSearchString(oldQueryOptions);
Expand Down Expand Up @@ -95,69 +75,10 @@ var GridSearch = Vue.extend({
},

search: function() {
if (this.hasSearchTag && this.searchString === '') {
this.searchTagSelection = undefined;
this.searchTagInput.setSelectedOption(this.searchTagSelection);
}

let searchQueryOptions =
uiCommonLib.searchUtils.getQueryOptions(this.searchString, this.occurrenceSelection);

this.$dispatch('search-grid-action', searchQueryOptions);
},

initSearchTagSelection() {

if (!this.hasSearchTag) {
return;
}

// search tag input
var elemSearchTags = $(this.$el).find('#searchTagsSelector .form-control');
this.searchTagInput = new uiCommonLib.DropdownSearchMenu(elemSearchTags, {
title: i18n.t('dropdownSearchMenu.title', {
entity: this.searchTagName
}),
searchPlaceholder: i18n.t('dropdownSearchMenu.searchPlaceholder', {
entity: this.searchTagName
})
});
// options
let options = this.searchTagOptions.map((tagOption) => {
return {
name: tagOption,
value: tagOption
};
});
this.searchTagInput.setOptions(options);
this.searchTagInput.setSelectedOption(this.searchTagSelection);

// select option
this.searchTagInput.setOptionSelectCallback((option) => {
this.searchTagSelection = option;

let tagSearchString = this.searchTagName + ':' + this.searchTagSelection.value;
let idxSearchTag = this.searchString.indexOf(this.searchTagName);
if (idxSearchTag > -1) {
// replace query string with new selection
this.searchString = tagSearchString + ' ';
} else {
// add search tag to query string
if (this.searchString.length > 0) {
this.searchString += ' ';
}
this.searchString += tagSearchString;
}

this.search();
});
// clear selection
this.searchTagInput.setClearOptionSelectCallback(() => {
this.searchTagSelection = undefined;
this.searchString = '';

this.search();
});
}
}
});
Expand Down
3 changes: 0 additions & 3 deletions ui/app/src/js/components/common/GridSearchVue.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@
@keyup.enter="onSearch($event)" />
</div>
</div>
<div v-if="searchTagName" id="searchTagsSelector" class="form-group search-tags-selection">
<div class="form-control dropdown-holder"></div>
</div>
</div>
14 changes: 7 additions & 7 deletions ui/app/src/js/components/common/ListTitleBigVue.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<span v-if="count > -1" class="total-items">({{count}})</span>
<div class="title-big-actions" v-if="!actionName" transition="fade-in">
<slot></slot>
<big-action-button v-bind:name="'refresh'"
v-bind:icon-name="'refresh'"
v-bind:label="i18n('refresh')"
v-bind:spinning="true"
<big-action-button :name="'refresh'"
:icon-name="'refresh'"
:label="i18n('refresh')"
:spinning="true"
></big-action-button>
</div>
<action-confirmation v-else v-bind:action-name="actionName"
v-bind:action-title="actionTitle"></action-confirmation>
</div>
<action-confirmation v-else :action-name="actionName"
:action-title="actionTitle"></action-confirmation>
</div>
10 changes: 5 additions & 5 deletions ui/app/src/js/components/common/ListTitleVue.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="title"><span>{{hasSearchQuery ? titleSearch : title}}</span><span
v-if="count > -1" class="total-items">({{count}})</span><span
v-if="!actionName" transition="fade-in"><refresh-button
v-on:click="notifyRefresh()"></refresh-button><slot></slot></span>
<action-confirmation v-else v-bind:action-name="actionName"
v-bind:action-title="actionTitle"></action-confirmation>
</div>
v-if="!actionName" transition="fade-in"><refresh-button
@click="notifyRefresh()"></refresh-button><slot></slot></span>
<action-confirmation v-else :action-name="actionName"
:action-title="actionTitle"></action-confirmation>
</div>
108 changes: 108 additions & 0 deletions ui/app/src/js/components/common/VueGridSearchTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright (c) 2018 VMware, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product may include a number of subcomponents with separate copyright notices
* and license terms. Your use of these subcomponents is subject to the terms and
* conditions of the subcomponent's license, as noted in the LICENSE file.
*/

import uiCommonLib from 'admiral-ui-common';

/**
* Tag selector for the grid search component.
*/
var VueGridSearchTag = Vue.extend({
template: `<div v-if="searchTagName" id="searchTagsSelector"
class="form-group search-tags-selection"><div
class="form-control dropdown-holder"></div></div>`,
props: {
queryOptions: {
type: Object,
required: true
},
searchTagName: {
type: String,
required: false
},
searchTagOptions: {
type: Array,
required: false
}
},

data: function() {
return {
searchTagSelection: undefined
};
},

attached: function() {
this.unwatchTagOptions = this.$watch('searchTagOptions', () => {
this.initSearchTagSelection();
}, { immediate: true });
},

detached: function() {
this.unwatchTagOptions();
},

methods: {
initSearchTagSelection() {
if (!this.searchTagName || !this.searchTagOptions) {
return;
}

// search tag input
var elemSearchTags = $(this.$el).parent().find('#searchTagsSelector .form-control');

this.searchTagInput = new uiCommonLib.DropdownSearchMenu(elemSearchTags, {
title: i18n.t('dropdownSearchMenu.title', {
entity: this.searchTagName
}),
searchPlaceholder: i18n.t('dropdownSearchMenu.searchPlaceholder', {
entity: this.searchTagName
})
});
// options
let options = this.searchTagOptions.map((tagOption) => {
return {
name: tagOption,
value: tagOption
};
});
this.searchTagInput.setOptions(options);

if (this.queryOptions && this.queryOptions[this.searchTagName]) {
this.searchTagSelection = {
name: this.queryOptions[this.searchTagName],
value: this.queryOptions[this.searchTagName]
};
}
this.searchTagInput.setSelectedOption(this.searchTagSelection);

// select option
this.searchTagInput.setOptionSelectCallback((option) => {
this.searchTagSelection = option;

this.$dispatch('search-option-select', {
name: this.searchTagName,
value: this.searchTagSelection.value
});
});

// clear selection
this.searchTagInput.setClearOptionSelectCallback(() => {
this.searchTagSelection = undefined;

this.$dispatch('search-option-select', null);
});
}
}
});

Vue.component('search-tag-selector', VueGridSearchTag);

export default VueGridSearchTag;
12 changes: 12 additions & 0 deletions ui/app/src/js/components/templates/TemplatesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,18 @@ var TemplatesViewVueComponent = Vue.extend({
this.doSearchAndFilter(queryOptions, this.selectedCategory);
},

changeSearchTagSelection: function($eventData) {
var qo = $.extend({}, this.queryOptions);

if ($eventData) {
qo[$eventData.name] = $eventData.value;
} else if (!$eventData) {
delete qo[this.searchTag];
}

this.search(qo);
},

selectCategory(categoryName, $event) {
this.doSearchAndFilter(this.queryOptions, categoryName);
$event.stopPropagation();
Expand Down
9 changes: 7 additions & 2 deletions ui/app/src/js/components/templates/TemplatesViewVue.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@
</a>
</span>
</span>

<search-tag-selector :query-options="queryOptions"
:search-tag-name="searchTag"
:search-tag-options="searchTagOptions"
@search-option-select="changeSearchTagSelection"
></search-tag-selector>
</div>
<div class="col-sm-6 toolbar-secondary">
<grid-search :query-options="queryOptions"
:placeholder="searchPlaceholder"
:search-tag-name="searchTag"
:search-tag-options="searchTagOptions"
:placeholder="searchPlaceholder"
@search-grid-action="search"></grid-search>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions ui/app/src/styles/components/_list-views.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
position: relative;
margin-right: 45px;

.search-tags-selection {
margin: 6px 0 0 0;
}

.search-form {
width: 100%;

Expand Down

0 comments on commit b70baa4

Please sign in to comment.