mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 21:00:39 +08:00
Add support for default text in messages component
This commit is contained in:
parent
f795ca4ad0
commit
d83a424d35
3 changed files with 30 additions and 10 deletions
|
@ -29,6 +29,7 @@ export interface Message {
|
|||
type: MessageTypes;
|
||||
text?: string;
|
||||
labelKey?: string;
|
||||
defaultText?: string;
|
||||
}
|
||||
|
||||
export enum MessageTypes {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
class="message {{ message.type }} alert-dismissible fade show shadow"
|
||||
[@fade]
|
||||
role="alert">
|
||||
<ng-container *ngIf="message.labelKey">{{appStrings[message.labelKey] || message.labelKey || ''}}</ng-container>
|
||||
<ng-container *ngIf="message.labelKey">{{appStrings[message?.labelKey] || message?.defaultText || message?.labelKey || ''}}</ng-container>
|
||||
<ng-container *ngIf="message.text && !message.labelKey">{{message.text}}</ng-container>
|
||||
<a (click)="close(message)" type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
|
|
|
@ -109,11 +109,17 @@ export class MessageService {
|
|||
});
|
||||
}
|
||||
|
||||
addSuccessMessageByKey(labelKey: string): number {
|
||||
return this.addMessage({
|
||||
addSuccessMessageByKey(labelKey: string, defaultText:string = null): number {
|
||||
const message = {
|
||||
type: MessageTypes.success,
|
||||
labelKey
|
||||
});
|
||||
} as Message;
|
||||
|
||||
if (defaultText) {
|
||||
message.defaultText = defaultText;
|
||||
}
|
||||
|
||||
return this.addMessage(message);
|
||||
}
|
||||
|
||||
addDangerMessage(text: string): number {
|
||||
|
@ -123,11 +129,18 @@ export class MessageService {
|
|||
});
|
||||
}
|
||||
|
||||
addDangerMessageByKey(labelKey: string): number {
|
||||
return this.addMessage({
|
||||
addDangerMessageByKey(labelKey: string, defaultText: string = null): number {
|
||||
|
||||
const message = {
|
||||
type: MessageTypes.danger,
|
||||
labelKey
|
||||
});
|
||||
} as Message;
|
||||
|
||||
if (defaultText) {
|
||||
message.defaultText = defaultText;
|
||||
}
|
||||
|
||||
return this.addMessage(message);
|
||||
}
|
||||
|
||||
addWarningMessage(text: string): number {
|
||||
|
@ -137,11 +150,17 @@ export class MessageService {
|
|||
});
|
||||
}
|
||||
|
||||
addWarningMessageByKey(labelKey: string): number {
|
||||
return this.addMessage({
|
||||
addWarningMessageByKey(labelKey: string, defaultText: string = null): number {
|
||||
const message = {
|
||||
type: MessageTypes.warning,
|
||||
labelKey
|
||||
});
|
||||
} as Message;
|
||||
|
||||
if (defaultText) {
|
||||
message.defaultText = defaultText;
|
||||
}
|
||||
|
||||
return this.addMessage(message);
|
||||
}
|
||||
|
||||
addInfoMessage(text: string): number {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue