Skip to content

Commit

Permalink
feat(permissions): add [loading] property to display an loader when p…
Browse files Browse the repository at this point in the history
…roperty is true.
  • Loading branch information
William Aguera committed Jul 8, 2019
1 parent 112e43e commit 3f54ead
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

export const Permissions = {
notFound: 'Nothing Found',
loadingMessage: 'Loading Permissions...',
searchGroup: 'Search Group...',
searchFunctionality: 'Search Functionality...',
allowColumnText: 'Allow'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

export interface PermissionsI18nInterface {
notFound: string;
loadingMessage: string;
searchGroup: string;
searchFunctionality: string;
allowColumnText: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

export const Permissions = {
notFound: 'Nada Encontrado',
loadingMessage: 'Carregando Permissões...',
searchGroup: 'Procurar Grupo...',
searchFunctionality: 'Procurar Funcionalidade...',
allowColumnText: 'Permitir'
Expand Down
2 changes: 2 additions & 0 deletions projects/truly-ui/src/components/permissions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { InputModule } from '../input/index';
import { PermissionGroupDirective } from './parts/directives/permission-group.directive';
import { A11yModule } from '@angular/cdk/a11y';
import { MiscModule } from '../misc/index';
import { LoaderModule } from '../loader/index';

@NgModule({
imports: [
Expand All @@ -16,6 +17,7 @@ import { MiscModule } from '../misc/index';
FormsModule,
InputModule,
CheckBoxModule,
LoaderModule,
MiscModule
],
declarations: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

&::-webkit-scrollbar-thumb {
background: map-deep-get($primary, "default", "foreground");
background: map-deep-get($primary, "default", "background");
}
}

Expand All @@ -41,8 +41,13 @@
}

}

.ui-loader-message {
color: rgba( map-deep-get($theme, $action, "default", "foreground"), 0.3);
}

.nothing-shown {
color: map-deep-get($theme, $action, "default", "foreground");
color: rgba( map-deep-get($theme, $action, "default", "foreground"), 0.3);
}

.ui-permissions-header {
Expand Down
16 changes: 14 additions & 2 deletions projects/truly-ui/src/components/permissions/permissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
</div>
<div class="ui-container-permissions">
<div class="ui-permissions-panel">
<div class="nothing-shown" *ngIf="dataSource?.length === 0">
<div class="ui-loader-wrapper" *ngIf="loading">
<div class="ui-loader">
<tl-loader></tl-loader>
</div>
<span class="ui-loader-message">{{ loadingMessage }}</span>
</div>
<div class="nothing-shown" *ngIf="dataSource?.length === 0 && !loading">
<span class="not-found-text">{{ notFound }}</span>
</div>
<ul #listGroup class="ui-permission-list" [style.display]="dataSource?.length > 0 ? 'block' : 'none'">
Expand All @@ -58,7 +64,13 @@
</ul>
</div>
<div class="ui-permissions-detail-panel">
<div class="nothing-shown" *ngIf="!selected || dataSourceSelected?.length === 0">
<div class="ui-loader-wrapper" *ngIf="loading">
<div class="ui-loader">
<tl-loader></tl-loader>
</div>
<span class="ui-loader-message">{{ loadingMessage }}</span>
</div>
<div class="nothing-shown" *ngIf="(!selected || dataSourceSelected?.length === 0) && !loading">
<i *ngIf="dataSourceSelected?.length !== 0 && !selected" class="ion-android-time"></i>
<span *ngIf="dataSourceSelected?.length === 0" class="not-found-text">{{ notFound }}</span>
</div>
Expand Down
21 changes: 21 additions & 0 deletions projects/truly-ui/src/components/permissions/permissions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,31 @@
}
.not-found-text {
font-size: 2em;
font-variant: all-petite-caps;
}
}
}


.ui-loader-wrapper {
width: 100%;
height: 100%;
display: flex;
align-items: center;
place-content: center;
flex-flow: column;
.ui-loader {
width: 50px;
height: 50px;
}
.ui-loader-message {
font-size: 16px;
white-space: nowrap;
font-variant: all-petite-caps;
}
}


.ui-permissions-header {
display: flex;
> .ui-panel-search-1 {
Expand Down
4 changes: 4 additions & 0 deletions projects/truly-ui/src/components/permissions/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class TlPermissions implements OnInit, AfterContentInit, AfterViewInit, O

@Input() color = 'basic';

@Input() loading = false;

@Input() keyGroup = 'description';

@Input() keyPermissions = 'permissions';
Expand Down Expand Up @@ -85,6 +87,8 @@ export class TlPermissions implements OnInit, AfterContentInit, AfterViewInit, O

public dataSourceSelected: any = [];

public loadingMessage = this.i18n.getLocale().Permissions.loadingMessage;

public notFound = this.i18n.getLocale().Permissions.notFound;

public searchGroup = this.i18n.getLocale().Permissions.searchGroup;
Expand Down

0 comments on commit 3f54ead

Please sign in to comment.