Skip to content

Commit

Permalink
widget: Alert component removal
Browse files Browse the repository at this point in the history
* BETTER Alert component has been removed as it is replaced by
ngx-toastr.

Signed-off-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma committed Oct 9, 2019
1 parent 62e0f71 commit 4a40d65
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 283 deletions.
80 changes: 47 additions & 33 deletions projects/ng-core-tester/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component } from '@angular/core';

import { DialogService, ApiService, TranslateLanguageService, AlertService } from '@rero/ng-core';
import { DialogService, ApiService, TranslateLanguageService } from '@rero/ng-core';
import { DocumentComponent } from '../record/document/document.component';
import { InstitutionComponent } from '../record/institution/institution.component';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'app-home',
Expand Down Expand Up @@ -33,41 +34,54 @@ export class HomeComponent {
private dialogService: DialogService,
private apiService: ApiService,
private translateLanguageService: TranslateLanguageService,
private alertService: AlertService
) {
this.apiData = {
relative: this.apiService.getEndpointByType('documents'),
absolute: this.apiService.getEndpointByType('documents', true),
};
private toastrService: ToastrService
) {
this.apiData = {
relative: this.apiService.getEndpointByType('documents'),
absolute: this.apiService.getEndpointByType('documents', true),
};

this.testLanguageTranslation = this.translateLanguageService.translate('fr', 'fr');
}

showDialog() {
const config = {
ignoreBackdropClick: true,
initialState: {
title: 'Confirmation',
body: 'Exit without saving changes?',
confirmButton: true
}
};
this.testLanguageTranslation = this.translateLanguageService.translate('fr', 'fr');
}

this.dialogService.show(config).subscribe((confirm: boolean) => {
if (confirm) {
console.log('Confirmed !');
}
});
}
showDialog() {
const config = {
ignoreBackdropClick: true,
initialState: {
title: 'Confirmation',
body: 'Exit without saving changes?',
confirmButton: true
}
};

doSearch(searchText: string) {
console.log(`You search for: ${searchText}`);
}
this.dialogService.show(config).subscribe((confirm: boolean) => {
if (confirm) {
console.log('Confirmed !');
}
});
}

addAlert() {
const type = (document.getElementById('alert-type')) as HTMLSelectElement;
const message = (document.getElementById('alert-message')) as HTMLInputElement;
doSearch(searchText: string) {
console.log(`You search for: ${searchText}`);
}

this.alertService.addAlert(type.value, message.value);
addAlert() {
const type = (document.getElementById('alert-type')) as HTMLSelectElement;
const message = (document.getElementById('alert-message')) as HTMLInputElement;
switch (type.value) {
// Checkbox controls
case 'success':
this.toastrService.success(message.value);
break;
case 'info':
this.toastrService.info(message.value);
break;
case 'warning':
this.toastrService.warning(message.value);
break;
case 'danger':
this.toastrService.error(message.value);
break;
}
}
}
}
25 changes: 0 additions & 25 deletions projects/rero/ng-core/src/lib/alert/alert.component.html

This file was deleted.

84 changes: 0 additions & 84 deletions projects/rero/ng-core/src/lib/alert/alert.component.spec.ts

This file was deleted.

67 changes: 0 additions & 67 deletions projects/rero/ng-core/src/lib/alert/alert.component.ts

This file was deleted.

36 changes: 0 additions & 36 deletions projects/rero/ng-core/src/lib/alert/alert.service.spec.ts

This file was deleted.

32 changes: 0 additions & 32 deletions projects/rero/ng-core/src/lib/alert/alert.service.ts

This file was deleted.

5 changes: 0 additions & 5 deletions projects/rero/ng-core/src/lib/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import { FormsModule } from '@angular/forms';
import { TranslateModule, TranslateLoader as BaseTranslateLoader } from '@ngx-translate/core';
import { ModalModule } from 'ngx-bootstrap/modal';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { AlertModule } from 'ngx-bootstrap/alert';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { PaginationModule } from 'ngx-bootstrap/pagination';
import { ToastrModule } from 'ngx-toastr';

import { TranslateLoader } from './translate/translate-loader';
import { AlertComponent } from './alert/alert.component';
import { SearchInputComponent } from './search-input/search-input.component';
import { Nl2brPipe } from './pipe/nl2br.pipe';
import { TranslateLanguagePipe } from './translate-language/translate-language.pipe';
Expand All @@ -37,7 +35,6 @@ import { DialogComponent } from './dialog/dialog.component';

@NgModule({
declarations: [
AlertComponent,
DialogComponent,
SearchInputComponent,
Nl2brPipe,
Expand All @@ -49,7 +46,6 @@ import { DialogComponent } from './dialog/dialog.component';
imports: [
CommonModule,
FormsModule,
AlertModule.forRoot(),
ModalModule.forRoot(),
BsDropdownModule.forRoot(),
CollapseModule.forRoot(),
Expand All @@ -69,7 +65,6 @@ import { DialogComponent } from './dialog/dialog.component';
PaginationModule,
BsDropdownModule,
TranslateModule,
AlertComponent,
DialogComponent,
SearchInputComponent,
Nl2brPipe,
Expand Down
1 change: 0 additions & 1 deletion projects/rero/ng-core/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export * from './lib/dialog/dialog.component';
export * from './lib/dialog/dialog.service';
export * from './lib/api/api.service';
export * from './lib/record/record.service';
export * from './lib/alert/alert.service';
export * from './lib/translate-language/translate-language.service';
export * from './lib/record/search/result/item/result-item';
export * from './lib/record/record.module';
Expand Down

0 comments on commit 4a40d65

Please sign in to comment.