Commit 1e0e27fc authored by Simon Knox's avatar Simon Knox

clean up formatting in vue templates

parent 4a4adbe2
<template> <template>
<!-- TODO: handle Delete button with btn-danger class and method delete to link_to current_board_path(board) -->
<popup-dialog <popup-dialog
v-show="currentPage" v-show="currentPage"
:title="title" :title="title"
...@@ -9,7 +8,7 @@ ...@@ -9,7 +8,7 @@
@toggle="cancel" @toggle="cancel"
@submit="submit" @submit="submit"
> >
<p v-if="currentPage === 'delete'"> <p v-if="isDeleteForm">
Are you sure you want to delete this board? Are you sure you want to delete this board?
</p> </p>
<form <form
...@@ -20,7 +19,10 @@ ...@@ -20,7 +19,10 @@
v-if="!readonly" v-if="!readonly"
class="append-bottom-20" class="append-bottom-20"
> >
<label class="form-section-title label-light" for="board-new-name"> <label
class="form-section-title label-light"
for="board-new-name"
>
Board name Board name
</label> </label>
<input <input
...@@ -48,13 +50,11 @@ ...@@ -48,13 +50,11 @@
{{ expandButtonText }} {{ expandButtonText }}
</button> </button>
</div> </div>
<p class="light append-bottom-10">
Board scope affects which issues are displayed for anyone who visits this board
</p>
<div v-if="!collapseScope || expanded"> <div v-if="!collapseScope || expanded">
<p class="light append-bottom-10"> <form-block>
Board scope affects which issues are displayed for anyone who visits this board
</p>
<form-block
>
<div <div
v-if="board.milestone" v-if="board.milestone"
slot="currentValue" slot="currentValue"
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
:milestone-path="milestonePath" :milestone-path="milestonePath"
v-model="board.milestone_id" v-model="board.milestone_id"
title="Milestone" title="Milestone"
defaultText="Any milestone" default-text="Any milestone"
:can-edit="canAdminBoard" :can-edit="canAdminBoard"
/> />
</form-block> </form-block>
...@@ -98,18 +98,13 @@ ...@@ -98,18 +98,13 @@
/> />
</form-block> </form-block>
<form-block <form-block>
title="Weight"
defaultText="Any weight"
field-name="'board_filter[weight]'"
:can-edit="canAdminBoard"
>
<board-weight-select <board-weight-select
:board="board" :board="board"
:weights="weightsArray" :weights="weightsArray"
v-model="board.weight" v-model="board.weight"
title="Weight" title="Weight"
defaultText="Any weight" default-text="Any weight"
:can-edit="canAdminBoard" :can-edit="canAdminBoard"
/> />
</form-block> </form-block>
...@@ -198,29 +193,38 @@ export default Vue.extend({ ...@@ -198,29 +193,38 @@ export default Vue.extend({
UserSelect, UserSelect,
}, },
computed: { computed: {
isNewForm() {
return this.currentPage === 'new';
},
isDeleteForm() {
return this.currentPage === 'delete';
},
isEditForm() {
return this.currentPage === 'edit';
},
buttonText() { buttonText() {
if (this.currentPage === 'new') { if (this.isNewForm) {
return 'Create'; return 'Create';
} }
if (this.currentPage === 'delete') { if (this.isDeleteForm) {
return 'Delete'; return 'Delete';
} }
return 'Save'; return 'Save';
}, },
buttonKind() { buttonKind() {
if (this.currentPage === 'delete') { if (this.isDeleteForm) {
return 'danger'; return 'danger';
} }
return 'info'; return 'info';
}, },
title() { title() {
if (this.currentPage === 'new') { if (this.isNewForm) {
return 'Create new board'; return 'Create new board';
} }
if (this.currentPage === 'delete') { if (this.isDeleteForm) {
return 'Delete board'; return 'Delete board';
} }
...@@ -237,7 +241,7 @@ export default Vue.extend({ ...@@ -237,7 +241,7 @@ export default Vue.extend({
return this.expanded ? 'Collapse' : 'Expand'; return this.expanded ? 'Collapse' : 'Expand';
}, },
collapseScope() { collapseScope() {
return this.currentPage === 'new'; return this.isNewForm;
}, },
readonly() { readonly() {
return !this.canAdminBoard; return !this.canAdminBoard;
...@@ -248,10 +252,10 @@ export default Vue.extend({ ...@@ -248,10 +252,10 @@ export default Vue.extend({
}, },
methods: { methods: {
submit() { submit() {
if (this.currentPage === 'delete') { if (this.isDeleteForm) {
this.submitDisabled = true; this.submitDisabled = true;
this.$http.delete(this.boardPath) this.$http.delete(this.boardPath)
.then(({redirect_to}) => { .then(() => {
gl.utils.visitUrl(Store.rootPath); gl.utils.visitUrl(Store.rootPath);
}) })
.catch(() => { .catch(() => {
...@@ -272,17 +276,21 @@ export default Vue.extend({ ...@@ -272,17 +276,21 @@ export default Vue.extend({
cancel() { cancel() {
Store.state.currentPage = ''; Store.state.currentPage = '';
}, },
resetFormState() {
if (this.currentBoard && Object.keys(this.currentBoard).length && this.isEditForm) {
Store.updateBoardConfig(this.currentBoard);
} else if (this.isNewForm) {
// Clear the form when we open the "New board" modal
Store.updateBoardConfig();
}
if (!this.board.labels) {
this.board.labels = [];
}
},
}, },
mounted() { mounted() {
if (this.currentBoard && Object.keys(this.currentBoard).length && this.currentPage !== 'new') { this.resetFormState();
Store.updateBoardConfig(this.currentBoard);
} else {
Store.updateBoardConfig();
}
if (!this.board.labels) {
this.board.labels = [];
}
if (this.$refs.name) { if (this.$refs.name) {
this.$refs.name.focus(); this.$refs.name.focus();
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<div class="block labels"> <div class="block labels">
<div class="title append-bottom-10"> <div class="title append-bottom-10">
Labels Labels
<i aria-hidden="true" class="fa fa-spinner fa-spin block-loading" data-hidden="true" style="display: none;"></i>
<a <a
v-if="canEdit" v-if="canEdit"
class="edit-link pull-right" class="edit-link pull-right"
...@@ -12,7 +11,10 @@ ...@@ -12,7 +11,10 @@
</a> </a>
</div> </div>
<div class="value issuable-show-labels"> <div class="value issuable-show-labels">
<span v-if="board.labels.length === 0" class="no-value"> <span
v-if="board.labels.length === 0"
class="no-value"
>
Any label Any label
</span> </span>
<a <a
...@@ -22,15 +24,20 @@ ...@@ -22,15 +24,20 @@
> >
<span <span
class="label color-label has-tooltip" class="label color-label has-tooltip"
:style="`background-color: ${label.color}; color: ${label.textColor};`" :style="`
background-color: ${label.color};
color: ${label.textColor};
`"
title="" title=""
> >
{{ label.title }} {{ label.title }}
</span> </span>
</a> </a>
</div> </div>
<div class="selectbox" style="display: none"> <div
class="selectbox"
style="display: none"
>
<input <input
type="hidden" type="hidden"
name="label_id[]" name="label_id[]"
...@@ -38,34 +45,46 @@ ...@@ -38,34 +45,46 @@
:key="labelId" :key="labelId"
:value="labelId" :value="labelId"
> >
<div class="dropdown"> <div class="dropdown">
<button <button
v-bind:data-labels="labelsPath"
class="dropdown-menu-toggle wide js-label-select js-multiselect js-board-config-modal" class="dropdown-menu-toggle wide js-label-select js-multiselect js-board-config-modal"
data-field-name="label_id[]" data-field-name="label_id[]"
v-bind:data-labels="labelsPath"
data-toggle="dropdown" data-toggle="dropdown"
type="button" type="button"
> >
<span class="dropdown-toggle-text"> <span class="dropdown-toggle-text">
Label Label
</span> <i aria-hidden="true" class="fa fa-chevron-down" data-hidden="true"></i> </span>
<i
aria-hidden="true"
class="fa fa-chevron-down"
data-hidden="true"
/>
</button> </button>
<div class="dropdown-menu dropdown-select dropdown-menu-paging dropdown-menu-labels dropdown-menu-selectable"> <div class="dropdown-menu dropdown-select dropdown-menu-paging dropdown-menu-labels dropdown-menu-selectable">
<div class="dropdown-input"> <div class="dropdown-input">
<input <input
autocomplete="off" autocomplete="off"
class="dropdown-input-field" id="" class="dropdown-input-field"
placeholder="Search" placeholder="Search"
type="search" type="search"
value=""
> >
<i aria-hidden="true" class="fa fa-search dropdown-input-search" data-hidden="true"></i> <i
<i aria-hidden="true" class="fa fa-times dropdown-input-clear js-dropdown-input-clear" data-hidden="true" role="button"></i> aria-hidden="true"
class="fa fa-search dropdown-input-search"
data-hidden="true"
/>
<i
aria-hidden="true"
class="fa fa-times dropdown-input-clear js-dropdown-input-clear"
data-hidden="true"
role="button"
/>
</div> </div>
<div class="dropdown-content"></div> <div class="dropdown-content"></div>
<div class="dropdown-loading"> <div class="dropdown-loading">
<i aria-hidden="true" class="fa fa-spinner fa-spin" data-hidden="true"></i> <loading-icon />
</div> </div>
</div> </div>
</div> </div>
...@@ -111,12 +130,6 @@ export default { ...@@ -111,12 +130,6 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
isOpen: false,
loading: true,
};
},
components: { components: {
loadingIcon, loadingIcon,
}, },
...@@ -125,17 +138,6 @@ export default { ...@@ -125,17 +138,6 @@ export default {
return this.selected.map(label => label.id).join(','); return this.selected.map(label => label.id).join(',');
}, },
}, },
methods: {
open() {
this.isOpen = true;
},
close() {
this.isOpen = false;
},
toggle() {
this.isOpen = !this.isOpen;
},
},
mounted() { mounted() {
new LabelsSelect(); new LabelsSelect();
}, },
......
<template> <template>
<div class="block" :class="wrapperClass"> <div
class="block"
:class="wrapperClass"
>
<div class="title append-bottom-10"> <div class="title append-bottom-10">
{{ label }} {{ label }}
<a <a
...@@ -25,7 +28,6 @@ ...@@ -25,7 +28,6 @@
<div class="bold author"> <div class="bold author">
{{ selected.name }} {{ selected.name }}
</div> </div>
<div class="username"> <div class="username">
@{{ selected.username }} @{{ selected.username }}
</div> </div>
...@@ -36,8 +38,10 @@ ...@@ -36,8 +38,10 @@
</div> </div>
</div> </div>
<div class="selectbox" style="display: none"> <div
class="selectbox"
style="display: none"
>
<div class="dropdown"> <div class="dropdown">
<button <button
class="dropdown-menu-toggle wide js-user-search js-author-search js-save-user-data js-board-config-modal" class="dropdown-menu-toggle wide js-user-search js-author-search js-save-user-data js-board-config-modal"
...@@ -55,23 +59,36 @@ ...@@ -55,23 +59,36 @@
> >
<span class="dropdown-toggle-text"> <span class="dropdown-toggle-text">
{{ placeholderText }} {{ placeholderText }}
</span> <i aria-hidden="true" class="fa fa-chevron-down" data-hidden="true"></i> </span>
<i
aria-hidden="true"
class="fa fa-chevron-down"
data-hidden="true"
/>
</button> </button>
<div class="dropdown-menu dropdown-select dropdown-menu-paging dropdown-menu-user dropdown-menu-selectable dropdown-menu-author"> <div class="dropdown-menu dropdown-select dropdown-menu-paging dropdown-menu-user dropdown-menu-selectable dropdown-menu-author">
<div class="dropdown-input"> <div class="dropdown-input">
<input <input
autocomplete="off" autocomplete="off"
class="dropdown-input-field" id="" class="dropdown-input-field"
placeholder="Search" placeholder="Search"
type="search" type="search"
value=""
> >
<i aria-hidden="true" class="fa fa-search dropdown-input-search" data-hidden="true"></i> <i
<i aria-hidden="true" class="fa fa-times dropdown-input-clear js-dropdown-input-clear" data-hidden="true" role="button"></i> aria-hidden="true"
class="fa fa-search dropdown-input-search"
data-hidden="true"
/>
<i
aria-hidden="true"
class="fa fa-times dropdown-input-clear js-dropdown-input-clear"
data-hidden="true"
role="button"
/>
</div> </div>
<div class="dropdown-content"></div> <div class="dropdown-content"></div>
<div class="dropdown-loading"> <div class="dropdown-loading">
<i aria-hidden="true" class="fa fa-spinner fa-spin" data-hidden="true"></i> <loading-icon />
</div> </div>
</div> </div>
</div> </div>
...@@ -81,6 +98,7 @@ ...@@ -81,6 +98,7 @@
<script> <script>
import UsersSelect from '~/users_select'; import UsersSelect from '~/users_select';
import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue'; import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
export default { export default {
...@@ -134,6 +152,7 @@ export default { ...@@ -134,6 +152,7 @@ export default {
}, },
}, },
components: { components: {
loadingIcon,
UserAvatarImage, UserAvatarImage,
}, },
computed: { computed: {
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
@click.prevent.stop="selectWeight(weight)"> @click.prevent.stop="selectWeight(weight)">
<i <i
class="fa fa-check" class="fa fa-check"
v-if="weight === value"></i> v-if="weight === value"
/>
{{ weight }} {{ weight }}
</a> </a>
</li> </li>
...@@ -62,7 +63,7 @@ export default { ...@@ -62,7 +63,7 @@ export default {
required: true, required: true,
}, },
value: { value: {
type: Number, type: [Number, String],
required: false, required: false,
}, },
defaultText: { defaultText: {
...@@ -94,7 +95,7 @@ export default { ...@@ -94,7 +95,7 @@ export default {
computed: { computed: {
weight() { weight() {
if (parseInt(this.board.weight, 10) === 0) { if (parseInt(this.board.weight, 10) === 0) {
return 'No weight'; return 'No Weight';
} }
return this.board.weight || 'Any weight'; return this.board.weight || 'Any weight';
}, },
......
...@@ -39,7 +39,7 @@ class FilteredSearchVisualTokens { ...@@ -39,7 +39,7 @@ class FilteredSearchVisualTokens {
static createVisualTokenElementHTML(canEdit = true) { static createVisualTokenElementHTML(canEdit = true) {
return ` return `
<div class="selectable" role="button" ${canEdit ? '' : 'style="display: none;"'}> <div class="selectable ${canEdit ? '' : 'hidden'}" role="button">
<div class="name"></div> <div class="name"></div>
<div class="value-container"> <div class="value-container">
<div class="value"></div> <div class="value"></div>
......
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
required: false, required: false,
default: false, default: false,
}, },
class: {
type: String,
required: false,
default: '',
},
}, },
computed: { computed: {
...@@ -25,7 +31,7 @@ ...@@ -25,7 +31,7 @@
return this.inline ? 'span' : 'div'; return this.inline ? 'span' : 'div';
}, },
cssClass() { cssClass() {
return `fa-${this.size}x`; return `fa-${this.size}x ${this.class}`;
}, },
}, },
}; };
......
...@@ -60,7 +60,9 @@ export default { ...@@ -60,7 +60,9 @@ export default {
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<slot name="header"> <slot name="header">
<h4 class="modal-title pull-left">{{this.title}}</h4> <h4 class="modal-title pull-left">
{{this.title}}
</h4>
<button <button
type="button" type="button"
class="close pull-right" class="close pull-right"
...@@ -83,13 +85,15 @@ export default { ...@@ -83,13 +85,15 @@ export default {
class="btn pull-left" class="btn pull-left"
:disabled="submitDisabled" :disabled="submitDisabled"
:class="btnKindClass" :class="btnKindClass"
@click="emitSubmit(true)"> @click="emitSubmit(true)"
>
{{primaryButtonLabel}} {{primaryButtonLabel}}
</button> </button>
<button <button
type="button" type="button"
class="btn btn-default pull-right" class="btn btn-default pull-right"
@click="close"> @click="close"
>
Cancel Cancel
</button> </button>
</div> </div>
...@@ -101,6 +105,6 @@ export default { ...@@ -101,6 +105,6 @@ export default {
<div <div
class="modal-backdrop fade in" class="modal-backdrop fade in"
@click="close" @click="close"
></div> />
</div> </div>
</template> </template>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment