Skip to content

Commit 67807b5

Browse files
committed
broadcast.js init
1 parent 3c7ab72 commit 67807b5

27 files changed

+395
-19
lines changed

src/broadcast-typescript/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# broadcast-typescript
22

3-
Minimal Vite + TypeScript project configured to output a single JavaScript file `dist/bundle.js`.
3+
Minimal Vite + TypeScript project configured to output a single JavaScript file `dist/broadcast.js`.
44

55
Try it:
66

77
1. cd src/broadcast-typescript
88
2. npm install
99
3. npm run build
10-
4. Check `dist/bundle.js`
10+
4. Check `dist/broadcast.js`

src/broadcast-typescript/app/main.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,22 @@ import AppModule from './modules';
22

33
// Example runtime usage during build verification
44
if (typeof window !== 'undefined') {
5+
// Ensure runtime enums used by forms (XrmEnum/FormType) exist. Type declarations
6+
// in `types/globals.d.ts` only provide types — this creates a small runtime
7+
// object so code that references `XrmEnum` doesn't throw during onload.
8+
const runtimeXrmEnum = (globalThis as any).XrmEnum ?? {
9+
FormType: {
10+
Undefined: 0,
11+
Create: 1,
12+
Update: 2,
13+
ReadOnly: 3,
14+
Disabled: 4,
15+
QuickCreate: 5,
16+
BulkEdit: 6,
17+
ReadOptimized: 11
18+
}
19+
};
20+
(globalThis as any).XrmEnum = runtimeXrmEnum;
21+
522
(window as any).broadcast = (window as any).broadcast ?? AppModule;
623
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as system from "./system"
2-
3-
2+
import * as utility from "./utility";
43

54
export default {
6-
system
5+
system,
6+
utility
77
};
88

99

1010

11+
12+

src/broadcast-typescript/app/modules/common/system/localization/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ import Resource from './Resource'
44
const resources = {
55
"general": {
66
MESSAGE_RECORD_DIRTY: new Resource("You have pending changes, please save the record.", "Vous avez des modifications en attente de sauvegarde. Veuillez sauvegarder."),
7-
WAIT_POPUPTITLE: new Resource("Wait!", "Attendez!")
7+
WAIT_POPUPTITLE: new Resource("Wait!", "Attendez!"),
8+
CANCEL_BTN: new Resource("Cancel", "Annuler"),
9+
PROCESSING: new Resource("Processing...", "En traitement...")
810
},
9-
"salesorder": {
10-
MESSAGE_FOLLOWUP_INVALID: new Resource("Must be the current date, future date or none.", "Doit être la date du jour, date future ou aucune"),
11-
MESSAGE_PREVENT_REVISION: new Resource("You are about to revise the order. This will reset the order process step to \“Validate\” and reset the tasks. Do you want to continue?",
12-
"La correction de la commande retournera le processus à l’étape « Confirmer » et réinitialisera les tâches. Voulez-vous continuer?")
11+
"broadcast": {
12+
PUBLISH_BTN: new Resource("Publish", "Publier"),
13+
UNPUBLISH_BTN: new Resource("Unpublish", "Dépublier"),
14+
NOTIFICATION_CONFIRMPUBLISH_TITLE: new Resource("Confirm Publish", "Confirmer la publication"),
15+
NOTIFICATION_CONFIRMPUBLISH_CONTENT: new Resource("Are you sure you want to publish this notification?\r\n\r\nThis notification will be shown to users.",
16+
"Êtes-vous sûr de vouloir publier cette notification?\r\n\r\nCette notification sera affichée aux utilisateurs."),
17+
NOTIFICATION_CONFIRMUNPUBLISH_TITLE: new Resource("Confirm Unpublish", "Confirmer la dépublication"),
18+
NOTIFICATION_CONFIRMUNPUBLISH_CONTENT: new Resource("Are you sure you want to unpublish this notification?\r\n\r\nThis notification will no longer be shown to users.",
19+
"Êtes-vous sûr de vouloir dépublier cette notification?\r\n\r\nCette notification ne sera plus affichée aux utilisateurs.")
1320

1421
}
1522

1623
};
1724

1825

19-
export default {
26+
export {
2027
resources
2128
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export function getUserLangFromGlobalContext(){
2+
const userLang = Xrm.Utility.getGlobalContext().userSettings.languageId;
3+
switch(userLang){
4+
case 1036:
5+
return 794560002;
6+
default:
7+
return 794560001;
8+
}
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {resources} from "@app/modules/common/system/localization";
2+
export async function notifyIfDirty(formContext: Xrm.FormContext): Promise<boolean> {
3+
if (formContext.data.entity.getIsDirty()) {
4+
await Xrm.Navigation.openAlertDialog({title:resources.general.WAIT_POPUPTITLE.toString(), text: resources.general.MESSAGE_RECORD_DIRTY.toString()});
5+
return true;
6+
}
7+
return false;
8+
}
9+
10+
export function registerOnChangeHandler(formContext:Xrm.FormContext,
11+
attributeName:string,handler: Xrm.Events.Attribute.ChangeEventHandler,
12+
callerObject:any):void{
13+
const attribute = formContext.getAttribute(attributeName);
14+
attribute?.addOnChange(handler.bind(callerObject));
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './primitive';
2+
export * from './form';
3+
export * from './context';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function cleanGuid(guid: string): string {
2+
return guid.replace("{", "").replace("}", "");
3+
}
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
import { entity } from ".";
2-
export class fdn_broadcastappnotification extends entity {
1+
import { entity ,fdn_localizednotificationcontent} from ".";
32

3+
export enum fdn_level {
4+
Success = 794560000,
5+
Danger = 794560001,
6+
Warning = 794560002,
7+
Information = 794560003
8+
}
9+
export class fdn_broadcastappnotification extends entity {
10+
fdn_level?: fdn_level;
11+
fdn_message?: string;
12+
fdn_name?: string;
13+
fdn_appmoduleid?: string
14+
fdn_broadcastappnotificationid?: string;
15+
fdn_localizednotificationcontent_AppNotificationConfigId_fdn_broadcastappnotification?:fdn_localizednotificationcontent[];
416
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { entity } from ".";
2+
3+
export type fdn_localizednotificationcontent = entity &{
4+
fdn_localizednotificationcontentid?:string;
5+
fdn_language?:number;
6+
fdn_name?:string;
7+
fdn_contentmessage?:string;
8+
}

0 commit comments

Comments
 (0)