Skip to content

Instantly share code, notes, and snippets.

@ZhenDeng
ZhenDeng / Child Component
Last active May 6, 2021 01:59
This snippet is used for one parent component with html and render different child component in html, could run different function body based on which child component being rendered
@Component({
selector: 'app-school-year-change',
templateUrl: './school-year-change.component.html',
styleUrls: ['./school-year-change.component.scss']
})
export class SchoolYearChangeComponent extends WorktrayComponentBase implements OnInit {
private _footerButtons: FooterButton[];
constructor(private ref: DynamicDialogRef) {
$.fn.showPostcodeAutoComplete = function (pcode) {
console.log(pcode);
$(this).autocomplete({
source: function (request, response) {
$.ajax({
url: 'api/checkout/GetPostCodeList',
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(pcode),
dataType: 'json',
import { ValidatorFn } from '@angular/forms';
export interface BooleanFn {
(): boolean;
}
/**
* A conditional validator generator. Assigns a validator to the form control if the predicate function returns true on the moment of validation
* @example
* Here if the myCheckbox is set to true, the myEmailField will be required and also the text will have to have the word 'mason' in the end.
IF NOT EXISTS(SELECT * FROM Isp.DocumentType WHERE Name = 'Withdrawal Travel Ticket')
BEGIN
insert into Isp.DocumentType(Name, SubType, Code, Description, IndexInSubtype) values ('Withdrawal Travel Ticket', 'Withdrawal', 'Withdrawal Travel Ticket', 'Withdrawal Travel Ticket', 0)
END
C#: public Dictionary<string, string> ExtensionData { get; set; }
Angular Model: ExtensionData: { [key: string]: string };
Implementation: this.worktrayItem.ExtensionData.SchoolTerm
this.schoolYearArray = [...new Set(this.attendanceDetails.map(item => item.SchoolYear))];
**** send data to component via resolver
1. create resolver file -- ate-resolver.service.ts
import {Injectable, Inject} from '@angular/core';
import {Resolve, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import { Observable } from 'rxjs';
import { APP_CONFIG, IAppConfig } from '../../config/app.config';
import { DataContextService } from 'src/app/service/datacontext.service';
import { ApplicationSection } from '../../enums';
import { ApplicationSectionTexts } from '../../constants/applicationSectionTexts';
export class ValidationData {
[ApplicationSection.ApplicationStudent]: SectionValidationData;
[ApplicationSection.ApplicationContact]: SectionValidationData;
[ApplicationSection.ApplicationStudentVisa]: SectionValidationData;
[ApplicationSection.ApplicationStudentSchoolProgram]: SectionValidationData;
[ApplicationSection.ApplicationStudentAccommodationWelfare]: SectionValidationData;
[ApplicationSection.ApplicationStudentEnglishProficiency]: SectionValidationData;
public class TerminateCourseService : ITerminateCourseService
{
public IVisaTerminationWorkflowService _visaTerminationWorkflow { get; set; }
public TerminateCourseService()
{
}
public ITerminationWorkflowService GetTerminationWorkflow(TerminationReason terminationReason) // because IVisaTerminationWorkflowService inherit from ITerminationWorkflowService
{
public async Task<int> AutoCreateWelfareManagementWorkTrayItems(int defaultRunTerm, int defaultRunWeek)
{
async Task<int> Func()
{
return worktrayItemsCreatedCount;
}
return await ExecuteAsync(Func);
}
public async Task<ServiceResponse<int>> TerminateCourse(DateTime dateTime)