show spinner on load for table & catalog components #1424
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
da04d409a3
commit
eae6a6f43c
|
@ -207,6 +207,8 @@ export default class CrudModel extends ModelProxy {
|
||||||
sendRequest(filter, append) {
|
sendRequest(filter, append) {
|
||||||
this.cancelRequest();
|
this.cancelRequest();
|
||||||
this.canceler = this.$q.defer();
|
this.canceler = this.$q.defer();
|
||||||
|
this.isRefreshing = !append;
|
||||||
|
this.isPaging = append;
|
||||||
|
|
||||||
let params = Object.assign(
|
let params = Object.assign(
|
||||||
{filter},
|
{filter},
|
||||||
|
@ -220,7 +222,10 @@ export default class CrudModel extends ModelProxy {
|
||||||
return this.$http.get(this._url, options).then(
|
return this.$http.get(this._url, options).then(
|
||||||
json => this.onRemoteDone(json, filter, append),
|
json => this.onRemoteDone(json, filter, append),
|
||||||
json => this.onRemoteError(json)
|
json => this.onRemoteError(json)
|
||||||
);
|
).finally(() => {
|
||||||
|
this.isRefreshing = false;
|
||||||
|
this.isPaging = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemoteDone(json, filter, append) {
|
onRemoteDone(json, filter, append) {
|
||||||
|
|
|
@ -321,6 +321,20 @@ export class Paginable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Boolean} Whether the model is refreshing.
|
||||||
|
*/
|
||||||
|
get isRefreshing() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Boolean} Whether the model is paging.
|
||||||
|
*/
|
||||||
|
get isPaging() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Boolean} Whether the data is paginated and there are more rows to load.
|
* @type {Boolean} Whether the data is paginated and there are more rows to load.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
<div class="table">
|
<div class="table">
|
||||||
<vn-empty-rows ng-if="$ctrl.model && !$ctrl.model.data" translate>
|
<vn-empty-rows ng-if="$ctrl.isRefreshing">
|
||||||
|
<vn-spinner enable="$ctrl.isRefreshing"></vn-spinner>
|
||||||
|
</vn-empty-rows>
|
||||||
|
<vn-empty-rows ng-if="!$ctrl.isRefreshing && $ctrl.model && !$ctrl.model.data" translate>
|
||||||
Enter a new search
|
Enter a new search
|
||||||
</vn-empty-rows>
|
</vn-empty-rows>
|
||||||
<vn-empty-rows ng-if="$ctrl.model.data.length === 0" translate>
|
<vn-empty-rows ng-if="!$ctrl.isRefreshing && $ctrl.model.data.length === 0" translate>
|
||||||
No results
|
No results
|
||||||
</vn-empty-rows>
|
</vn-empty-rows>
|
||||||
</div>
|
</div>
|
|
@ -14,6 +14,14 @@ export default class Table {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isRefreshing() {
|
||||||
|
return (this.model && this.model.isRefreshing);
|
||||||
|
}
|
||||||
|
|
||||||
|
get isPaging() {
|
||||||
|
return (this.model && this.model.isPaging);
|
||||||
|
}
|
||||||
|
|
||||||
setOrder(field, order) {
|
setOrder(field, order) {
|
||||||
this.field = field;
|
this.field = field;
|
||||||
this.order = order;
|
this.order = order;
|
||||||
|
|
|
@ -183,4 +183,11 @@ fieldset[disabled] .mdl-textfield .mdl-textfield__label,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vn-empty-rows {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
padding: 1.5em;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
|
@ -39,13 +39,19 @@
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-card
|
|
||||||
ng-if="!model.data || model.data.length == 0"
|
<vn-card margin-medium-top>
|
||||||
style="text-align: center"
|
<vn-empty-rows ng-if="$ctrl.isRefreshing">
|
||||||
margin-medium-top
|
<vn-spinner enable="$ctrl.isRefreshing"></vn-spinner>
|
||||||
pad-medium>
|
</vn-empty-rows>
|
||||||
<span translate>No results</span>
|
<vn-empty-rows ng-if="!$ctrl.isRefreshing && !model.data" translate>
|
||||||
|
Enter a new search
|
||||||
|
</vn-empty-rows>
|
||||||
|
<vn-empty-rows ng-if="!$ctrl.isRefreshing && model.data.length === 0" translate>
|
||||||
|
No results
|
||||||
|
</vn-empty-rows>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
||||||
<vn-horizontal class="catalog-list">
|
<vn-horizontal class="catalog-list">
|
||||||
<section class="product" ng-repeat="item in items">
|
<section class="product" ng-repeat="item in items">
|
||||||
<vn-card>
|
<vn-card>
|
||||||
|
|
|
@ -128,6 +128,10 @@ class Controller {
|
||||||
if (this.order && this.order.isConfirmed)
|
if (this.order && this.order.isConfirmed)
|
||||||
this.$state.go('order.card.line');
|
this.$state.go('order.card.line');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isRefreshing() {
|
||||||
|
return this.$scope.model && this.$scope.model.isRefreshing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$scope', '$state'];
|
Controller.$inject = ['$scope', '$state'];
|
||||||
|
|
Loading…
Reference in New Issue