0.4.7 • Published 5 years ago

edu.ucms.app v0.4.7

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

UCMS.Angular

צעדים ראשונים לשימוש בתשתית

  • **npm i edu.ucms.app --save**
  • יש להוסיף למודול הראשי את ה imports הבאים כדי שרכיבי התשתית יתנהלו כמו שצריך: UcmsSharedModule.forRoot(), HttpClientModule בנוסף כמובן ניתן לייבא את ה modules השונים בהתאם לצורך.
  • ל UcmsSharedModule יש לשלוח נתוני קונפיגורציה עבור השליפות מה SharePoint. ניתן לעשות זאת ע"י אספקת provider ושימוש ב MY_CONFIG_TOKEN באופן הבא: {provide: MY_CONFIG_TOKEN, useClass: ConfigService} וזאת כאשר ConfigService מממש את IConfig של ה UCMS ומכיל את ה data members הבאים מאותחלים כמו שצריך: AppId: string; //application code. Ex: Shr WebApiRootUrl: string; //url of ucms.api. Ex: http://ucms.stage.education.gov.il/UcmsApi/Api Lang: string; //application language. Ex: HE
  • ע"מ לתמוך בניווט יש  ליצור מודול (בפרויקט התשתית מצויה דוגמא כזו בשם AppRoutingModule) שמטפל בכל הענין הזה. מודול זה צורך את ה routerService של התשתית.
  • בשלב זה ניתן להטמיע את ה component על הדף:

קונפיגורציה

מבנה המחלקה ב Ucms:

ניווט

הניווט באפליקציה מתבסס על נתוני "רשימה לניווט" הקיימת ב SharePoint (נוצרת בהפעלת הפיצ'ר "יצירת סוגי תוכן ורשימות לתשתית פורטלים"). פירוט על רשימה זו ואופן השימוש בה ניתן למצוא במדריך לעורך תוכן.

האפליקציה החיצונית אחראית לבצע את הגדרת הניווט בפועל. מהקריאה ל NavigationController שבפרויקט ה api יחזרו כל הנתונים עבור הניווט בצורה הירארכית כפי שהם מופיעים ב SP. השלב הבא יהיה ליצור מודול ייעודי עבור הניווט - appRouting.module שיזין את הנתונים בצורה נכונה ל Router המובנה של אנגולר. עיקר העבודה הנעשית בפונקציה הרקורסיבית setConfig כפי הנראה למטה, זה לתאם בין שם הפריסה למודול המתאים לה. לאחר הריצה על כל הרשומות כולל קידוח עד הרמה הנמוכה ביותר של הניווט, יחזר מפונקציה זו מערך מתאים עם הגדרת path ו loadChildren לכל פריט. דוגמא למודול כזה:

export const ROUTES: Routes = [
{ path: 'tmp1', loadChildren: '../../modules/news-and-updates-page-wrap#NewsAndUpdatesPageWrapModule' },
{ path: 'tmp2', loadChildren: './pages/daf-sherut/daf-sherut.module#DafSherutModuleExt' },
{ path: 'tmp3', loadChildren: '../../pages/not-found/not-found.module#NotFoundPageModule' }
];

@NgModule({
    imports: [
        RouterModule.forRoot(
        [],
        {
            enableTracing: false, // <-- debugging purposes only
            initialNavigation: false
        }
        )
    ],
    declarations: [],
    exports: [
        RouterModule
    ],
    providers: [RouterService,
        { provide: APP_INITIALIZER, useFactory: init_app, deps: [Injector, RouterService], multi: true }
    ]
})
export class AppRoutingModule { }

export function init_app(injector: Injector, configService: RouterService): Function {
    try {
        return () => {
        configService.getNavigation().then((res) => {
            let router: Router = injector.get(Router);
            let routerConfig: Routes = [];
            configService.navigationItems = res;
            for (let nav of configService.navigationItems) {
            routerConfig = setConfig(nav, 0, routerConfig);
            }
            router.config.splice(0, router.config.length);
            router.config = router.config.concat(routerConfig);
        
            router.config.push({ path: 'not-found', loadChildren: () => NotFoundPageModule });
            router.config.push({ path: '**', redirectTo: 'not-found' });
            router.resetConfig(router.config)
            router.initialNavigation();
            configService.emitConfigLoaded();
        }, (reason) => {
            console.log(reason);
        });
        };
    }
    catch (err) {
        console.error(err);
    }
}

function setConfig(navigation, ind, routerConfig) {
    switch (navigation["PageName"]) {
        case "daf-nose": routerConfig.push({ path: navigation["Path"], loadChildren: () => DafSherutModuleExt });
        break;
        case "news-and-updates-page": routerConfig.push({ path: navigation["Path"], loadChildren: () => NewsAndUpdatesPageModule });
        break;
        default: break;
    }
    if (navigation["Children"]) {
        for (let nav of navigation["Children"]) {
        routerConfig = setConfig(nav, 0, routerConfig);
        }
    }

    return routerConfig;
}
<div style="direction:rtl; text-align:right">

#### צריכה של רכיבי התשתית ואזורי מידע מתחלף

לאחר יישום כל הגדרות הקונפיגורציה (והניווט אם יש בכך צורך), ניתן לייבא את המודול הרצוי ולצרוך את רכיב התשתית בהתאם לצורך.
צריכת רכיב שאלות ותשובות:
</div>

import { QuestionsAnswersModule } from 'edu.ucms.app';

@NgModule({ declarations: , imports: QuestionsAnswersModule … }) export class NewPageModule {

}

<div style="direction:rtl; text-align:right">
    כעת ניתן להטמיע על ה template של ה html את הרכיב באופן הבא ולהוסיף לו inputs בהתאם לצורך.
</div>

< questions-answers (setIsDisplay)="setDisplayQuestionsAnswers()" *ngIf="category" lang="'He'" appId="'Shr'" category='category'> < /questions-answers>

<div style="direction:rtl; text-align:right">
    בנוסף, ישנה אפשרות להכניס תוכן דינאמי עבור מידע מתחלף בתבנית של דף תוכן. ראשית יש לייבא את ה directive מתוך חבילת התשתית.
</div>

import { QueryFilterFields, ApiQuery, NetworkManagerService, ConfigurationService, BaseComponent, PersonalInfoHostDirective } from 'edu.ucms.app';

<div style="direction:rtl; text-align:right">
    וכן לייבא מתוך ה angular/core:
</div>

import { Component, OnInit, Output, ViewChild, ViewChildren, ComponentFactoryResolver, ElementRef, Type, QueryList, ChangeDetectorRef} from '@angular/core';

<div style="direction:rtl; text-align:right">
    ב HTML:
</div>

< ng-template personal-Info-host> < /ng-template>

<div style="direction:rtl; text-align:right">
    בצד ה TS הכרזה על משתנה מקושר לאלמנט:
</div>

@ViewChildren(PersonalInfoHostDirective) componentHost: QueryList < PersonalInfoHostDirective>;

<div style="direction:rtl; text-align:right">
    להלן פונקציה שמשתילה רכיב מתחלף ע"פ קלט כלשהו:
</div>

ngAfterViewInit() { switch (this._piComponent) { case "hatamot-kpi": this.component = HatamotKpiComponent; break; case "bagruyot-kpi": this.component = BagruyotKpiComponent; break; case "hasaot-kpi": this.component = HasaotKpiComponent; break; } if (this.component) { let componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.component); this.componentHost.forEach((item, ind) => { let viewContainerRef = item.viewContainerRef; /ניקוי האזור הדינאמי אם יש צורך רק בקומפוננטה אחת/ viewContainerRef.clear(); let componentRef = viewContainerRef.createComponent(componentFactory); this.changeDetectionRef.detectChanges(); }); } else { console.log("no component selector as " + this._piComponent); } }

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.199

5 years ago

0.4.192

5 years ago

0.4.191

5 years ago

0.4.19

5 years ago

0.4.18

5 years ago

0.4.17

5 years ago

0.4.16

5 years ago

0.4.15

5 years ago

0.4.14

5 years ago

0.4.13

5 years ago

0.4.12

5 years ago

0.4.11

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.45

5 years ago

0.3.44

5 years ago

0.3.43

5 years ago

0.3.42

5 years ago

0.3.41

5 years ago

0.3.40

5 years ago

0.3.39

5 years ago

0.3.38

5 years ago

0.3.37

5 years ago

0.3.35

5 years ago

0.3.34

5 years ago

0.3.33

5 years ago

0.3.32

5 years ago

0.3.31

5 years ago

0.3.30

5 years ago

0.3.28

5 years ago

0.3.27

5 years ago

0.3.26

5 years ago

0.3.25

5 years ago

0.3.24

5 years ago

0.3.23

5 years ago

0.3.22

5 years ago

0.3.21

5 years ago

0.3.20

5 years ago

0.3.19

5 years ago

0.3.18

5 years ago

0.3.17

5 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.14

5 years ago

0.3.13

5 years ago

0.3.12

5 years ago

0.3.11

5 years ago

0.3.10

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.99

5 years ago

0.0.98

5 years ago

0.0.97

5 years ago

0.0.96

6 years ago

0.0.95

6 years ago

0.0.94

6 years ago

0.0.93

6 years ago

0.0.92

6 years ago

0.0.91

6 years ago

0.0.90

6 years ago

0.0.89

6 years ago

0.0.88

6 years ago

0.0.87

6 years ago

0.0.86

6 years ago

0.0.84

6 years ago

0.0.83

6 years ago

0.0.82

6 years ago

0.0.81

6 years ago

0.0.80

6 years ago

0.0.79

6 years ago

0.0.78

6 years ago

0.0.77

6 years ago

0.0.76

6 years ago

0.0.75

6 years ago

0.0.74

6 years ago

0.0.73

6 years ago

0.0.72

6 years ago

0.0.71

6 years ago

0.0.70

6 years ago

0.0.69

6 years ago

0.0.68

6 years ago

0.0.67

6 years ago

0.0.66

6 years ago

0.0.65

6 years ago

0.0.64

6 years ago

0.0.63

6 years ago

0.0.62

6 years ago

0.0.61

6 years ago

0.0.60

6 years ago

0.0.59

6 years ago

0.0.58

6 years ago

0.0.57

6 years ago

0.0.56

6 years ago

0.0.55

6 years ago

0.0.54

6 years ago

0.0.53

6 years ago

0.0.52

6 years ago

0.0.51

6 years ago

0.0.50

6 years ago

0.0.49

6 years ago

0.0.48

6 years ago

0.0.47

6 years ago

0.0.46

6 years ago

0.0.45

6 years ago

0.0.44

6 years ago

0.0.43

6 years ago

0.0.42

6 years ago

0.0.41

6 years ago

0.0.40

6 years ago

0.0.39

6 years ago

0.0.38

6 years ago

0.0.37

6 years ago

0.0.36

6 years ago

0.0.35

6 years ago

0.0.34

6 years ago

0.0.33

6 years ago

0.0.32

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.27

6 years ago

0.0.25

6 years ago

0.0.26

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago