Move progress bar into the action button to stop components jumping
This commit is contained in:
parent
8b785823ab
commit
2937010e95
5 changed files with 57 additions and 45 deletions
|
|
@ -343,7 +343,7 @@ a:hover {
|
||||||
border-radius: @button-border-radius;
|
border-radius: @button-border-radius;
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
border-color: @global-border;
|
border-color: @global-border;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 4px;
|
||||||
text-transform:none !important;
|
text-transform:none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,7 +356,6 @@ a:hover {
|
||||||
background-color: rgba(180, 180, 180, 0.10);
|
background-color: rgba(180, 180, 180, 0.10);
|
||||||
border-color: @global-primary-background;
|
border-color: @global-primary-background;
|
||||||
color: @button-text-color;
|
color: @button-text-color;
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uk-button-danger {
|
.uk-button-danger {
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-observe-visibility="visibilityChanged" class="uk-margin-remove uk-padding-remove">
|
<div v-observe-visibility="visibilityChanged" class="uk-margin-remove uk-padding-remove">
|
||||||
<div v-if="taskStarted" ref="isPollingElement">
|
<button
|
||||||
<action-progress-bar
|
type="button"
|
||||||
v-if="taskStarted && hideOnRun"
|
:disabled="buttonDisabled"
|
||||||
:progress="progress"
|
class="uk-button uk-width-1-1 uk-position-relative"
|
||||||
:task-status="taskStatus"
|
:class="buttonClasses"
|
||||||
/>
|
@click="handleClick"
|
||||||
<!-- hideOnRun selects if the button hides, don't show progress bar if button doesn't hide. -->
|
>
|
||||||
<button
|
<action-progress-bar :progress="progress" :task-status="taskStatus" :in-button="true" />
|
||||||
v-if="canTerminate && taskRunning"
|
{{ buttonLabel }}
|
||||||
type="button"
|
</button>
|
||||||
class="uk-button uk-button-danger uk-margin-remove uk-float-right uk-width-1-1"
|
|
||||||
@click="terminateTask"
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
:disabled="isDisabled"
|
|
||||||
:hidden="taskStarted && hideOnRun"
|
|
||||||
class="uk-button uk-width-1-1"
|
|
||||||
:class="[
|
|
||||||
isDisabled ? 'uk-button-disabled' : '',
|
|
||||||
buttonPrimary ? 'uk-button-primary' : 'uk-button-default',
|
|
||||||
]"
|
|
||||||
@click="bootstrapTask"
|
|
||||||
>
|
|
||||||
{{ submitLabel }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<action-status-modal
|
<action-status-modal
|
||||||
ref="statusModal"
|
ref="statusModal"
|
||||||
:title="submitLabel"
|
:title="submitLabel"
|
||||||
|
|
@ -113,11 +92,6 @@ export default {
|
||||||
required: false,
|
required: false,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
hideOnRun: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
|
|
@ -132,8 +106,25 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
submitUrl() {
|
buttonDisabled() {
|
||||||
return this.thingActionUrl(this.thing, this.action);
|
return this.isDisabled || (this.taskRunning && !this.canTerminate);
|
||||||
|
},
|
||||||
|
buttonLabel() {
|
||||||
|
return this.taskRunning && this.canTerminate ? "Cancel" : this.submitLabel;
|
||||||
|
},
|
||||||
|
buttonClasses() {
|
||||||
|
const classes = [];
|
||||||
|
if (this.buttonDisabled) {
|
||||||
|
classes.push("uk-button-disabled");
|
||||||
|
}
|
||||||
|
if (this.taskRunning && this.canTerminate) {
|
||||||
|
classes.push("uk-button-danger");
|
||||||
|
} else if (this.buttonPrimary) {
|
||||||
|
classes.push("uk-button-primary");
|
||||||
|
} else {
|
||||||
|
classes.push("uk-button-default");
|
||||||
|
}
|
||||||
|
return classes.join(" ");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -177,6 +168,13 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
handleClick() {
|
||||||
|
if (this.taskStarted) {
|
||||||
|
this.terminateTask();
|
||||||
|
} else {
|
||||||
|
this.bootstrapTask();
|
||||||
|
}
|
||||||
|
},
|
||||||
visibilityChanged(isVisible) {
|
visibilityChanged(isVisible) {
|
||||||
if (isVisible && this.taskStarted != true) {
|
if (isVisible && this.taskStarted != true) {
|
||||||
this.checkExistingTasks();
|
this.checkExistingTasks();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="progress uk-margin-small">
|
<div class="progress uk-margin-small" :class="inButton ? 'in-button' : 'stand-alone'">
|
||||||
<div v-if="indeterminateProgressBar" class="indeterminate"></div>
|
<div v-if="indeterminateProgressBar" class="indeterminate"></div>
|
||||||
<div v-else class="determinate" :style="barWidthFromProgress"></div>
|
<div v-else class="determinate" :style="barWidthFromProgress"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -19,6 +19,11 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
inButton: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -41,7 +46,20 @@ export default {
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@import "../../assets/less/theme.less";
|
@import "../../assets/less/theme.less";
|
||||||
|
|
||||||
.progress {
|
.in-button {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 4px;
|
||||||
|
background-color: transparent;
|
||||||
|
border-radius: 0;
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stand-alone {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
:button-primary="false"
|
:button-primary="false"
|
||||||
:submit-data="{ x: 0, y: 0, z: -100 }"
|
:submit-data="{ x: 0, y: 0, z: -100 }"
|
||||||
:submit-label="' - '"
|
:submit-label="' - '"
|
||||||
:hide-on-run="false"
|
|
||||||
:can-terminate="false"
|
:can-terminate="false"
|
||||||
/>
|
/>
|
||||||
<action-button
|
<action-button
|
||||||
|
|
@ -22,7 +21,6 @@
|
||||||
:submit-data="{ x: 0, y: 0, z: 100 }"
|
:submit-data="{ x: 0, y: 0, z: 100 }"
|
||||||
:submit-label="'+'"
|
:submit-label="'+'"
|
||||||
:can-terminate="false"
|
:can-terminate="false"
|
||||||
:hide-on-run="false"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
:submit-label="'Autofocus'"
|
:submit-label="'Autofocus'"
|
||||||
:button-primary="true"
|
:button-primary="true"
|
||||||
:submit-on-event="'globalFastAutofocusEvent'"
|
:submit-on-event="'globalFastAutofocusEvent'"
|
||||||
:is-disabled="isAutofocusing"
|
|
||||||
@taskStarted="onAutofocus"
|
@taskStarted="onAutofocus"
|
||||||
@finished="afterAutofocus"
|
@finished="afterAutofocus"
|
||||||
@error="modalError"
|
@error="modalError"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue