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

Adding spinners and disabling buttons to indicate the user might have to wait a few seconds #1414

Merged
merged 4 commits into from May 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions assets/js/app/editor/Components/File.vue
Expand Up @@ -64,6 +64,7 @@
class="btn dropdown-item"
type="button"
:readonly="readonly"
data-patience="virtue"
@click="selectServerFile"
>
<i class="fas fa-fw fa-th"></i>
Expand All @@ -77,6 +78,9 @@
>
<i class="fas fa-fw fa-info-circle"></i>
{{ labels.button_edit_attributes }}
<small class="dim"
><i class="fas fa-external-link-square-alt"></i
></small>
</a>
</div>
</div>
Expand Down Expand Up @@ -223,9 +227,11 @@ export default {
},
});
window.$('.bootbox-input').attr('name', 'bootbox-input');
window.reEnablePatientButtons();
})
.catch(err => {
console.warn(err);
window.reEnablePatientButtons();
});
},
onDragEnter(e) {
Expand Down
6 changes: 6 additions & 0 deletions assets/js/app/editor/Components/Image.vue
Expand Up @@ -63,6 +63,7 @@
class="btn dropdown-item"
type="button"
:disabled="readonly"
data-patience="virtue"
@click="selectServerFile"
>
<i class="fas fa-fw fa-th"></i>
Expand All @@ -76,6 +77,9 @@
>
<i class="fas fa-fw fa-info-circle"></i>
{{ labels.button_edit_attributes }}
<small class="dim"
><i class="fas fa-external-link-square-alt"></i
></small>
</a>
</div>
</div>
Expand Down Expand Up @@ -263,9 +267,11 @@ export default {
},
});
window.$('.bootbox-input').attr('name', 'bootbox-input');
window.reEnablePatientButtons();
})
.catch(err => {
console.warn(err);
window.reEnablePatientButtons();
});
},
onDragEnter(e) {
Expand Down
1 change: 1 addition & 0 deletions assets/js/app/index.js
Expand Up @@ -5,4 +5,5 @@ import './listing';
import './editor';
import './login';
import './confirmation.js';
import './patience-is-a-virtue.js';
import './common.js';
1 change: 1 addition & 0 deletions assets/js/app/listing/Components/Table/Row/_Actions.vue
Expand Up @@ -4,6 +4,7 @@
<a
class="btn btn-secondary btn-block btn-sm text-nowrap"
:href="record.extras.editLink"
data-patience="virtue"
>
<i class="far fa-edit mr-1"></i> {{ labels.button_edit }}
</a>
Expand Down
27 changes: 27 additions & 0 deletions assets/js/app/patience-is-a-virtue.js
@@ -0,0 +1,27 @@
import $ from 'jquery';

$('*[data-patience]').on('click', function() {
const thisElement = $(this);
const thisIcon = thisElement.find('i');

// Bootstrap padding / margin like `mx-2` or `pt-3`
const addedPadding = thisIcon.attr('class').match(/[mp][tblrxy]-[0-5]/i);
const newClass =
'fas fa-w fa-cog fa-spin ' + (addedPadding ? addedPadding : '');

$(this).attr('data-original-class', thisIcon.attr('class'));
thisIcon.attr('class', newClass);

window.setTimeout(function() {
thisElement.attr('disabled', true);
}, 50);
});

window.reEnablePatientButtons = function() {
$('*[data-patience]').each(function() {
const thisIcon = $(this).find('i');

$(this).attr('disabled', false);
thisIcon.attr('class', $(this).attr('data-original-class'));
});
};
6 changes: 3 additions & 3 deletions assets/js/app/sidebar/Components/Menu/_SubMenu.vue
@@ -1,11 +1,11 @@
<template>
<ul class="link--menu">
<li v-if="item.link_new !== null" class="link--actions">
<a :href="item.link_new">
<a :href="item.link_new" data-patience="virtue">
<i class="fas fa-fw fa-magic mr-2"></i
><span>New {{ item.singular_name }}</span>
</a>
<a :href="item.link_listing">
<a :href="item.link_listing" data-patience="virtue">
<i class="fas fa-fw" :class="item.icon"></i>
<span>View {{ item.name }}</span>
</a>
Expand All @@ -17,7 +17,7 @@
:key="index"
>
<!-- eslint-enable -->
<a :href="subitem.editLink">
<a :href="subitem.editLink" data-patience="virtue">
<i class="fas fa-fw mr-2" :class="subitem.icon"></i>
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-if="subitem.name" v-html="subitem.name"></span>
Expand Down
2 changes: 1 addition & 1 deletion templates/content/_buttons.html.twig
Expand Up @@ -2,7 +2,7 @@

<div class="record-actions">

{{ macro.button('action.save', 'fa-save', 'success', {'type': 'submit', 'form': 'editcontent'}) }}
{{ macro.button('action.save', 'fa-save', 'success', {'type': 'submit', 'form': 'editcontent', 'data-patience': 'virtue'}) }}

{% if record.id %}
<div class="btn-group">
Expand Down
2 changes: 1 addition & 1 deletion templates/content/listing.html.twig
Expand Up @@ -52,7 +52,7 @@
</div>
<div class="card-body">
<p>
<a class="btn btn-primary" href="{{ path('bolt_content_new', { contentType: contentType.slug }) }}">
<a class="btn btn-primary" href="{{ path('bolt_content_new', { contentType: contentType.slug }) }}" data-patience="virtue">
{{ macro.icon('magic') }} {{ __('action.create_new') }} {{ contentType.singular_name }}
</a>
</p>
Expand Down