Initial Commit on git.saherelm.ir ...

This commit is contained in:
2026-08-09 20:40:25 +03:30
commit fd9a6224d2
614 changed files with 100744 additions and 0 deletions
@@ -0,0 +1,126 @@
import {
XCardAction,
XCardActionModel,
XCardContainerComponent,
} from './x-card.typings';
import { Subject, Subscription } from 'rxjs';
import { concatMap, map } from 'rxjs/operators';
import { nameof, isNullOrEmptyString } from 'x-framework-core';
import { Component, ChangeDetectionStrategy } from '@angular/core';
@Component({
// tslint:disable-next-line:component-selector
selector: 'x-card',
templateUrl: './x-card.component.html',
styleUrls: ['./x-card.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class XCardComponent extends XCardContainerComponent {
//
//#region Props ...
//
private ACTION_PROVIDER_SUBSCRIPTION: Subscription;
//#endregion
//
//#region LifeCycles ...
onChange(changeKeys: string[]) {
super.onChange(changeKeys);
//
//#region Action Provider Changed ...
//
const isActionProviderChanged = changeKeys.includes(
nameof<XCardComponent>('actionProvider')
);
if (isActionProviderChanged) {
this.registerActionProvider();
}
//#endregion
}
onDestroy() {
super.onDestroy();
//
this.unregisterActionProvider();
}
registerViewHandlers() {
super.registerViewHandlers();
//
this.registerActionProvider();
}
//#endregion
//
//#region UI Providers ...
isNoTextCard() {
return this.getResourceValue(this.title).pipe(
concatMap((title) =>
this.getResourceValue(this.subTitle).pipe(
map((subTitle) => {
return {
title,
subTitle,
};
}),
map((object) => {
return (
isNullOrEmptyString(object.title) &&
isNullOrEmptyString(object.subTitle)
);
})
)
)
);
}
//#endregion
//
//#region Private ...
//
//#region ActionProvider ...
private registerActionProvider() {
//
this.unregisterActionProvider();
//
if (!this.actionProvider) {
this.actionProvider = new Subject<XCardActionModel>();
}
//
// Handle Action Provider ...
this.ACTION_PROVIDER_SUBSCRIPTION = this.applyTakeUntilWrapper(
this.actionProvider.asObservable()
).subscribe(async (model) => {
//
if (!model) {
return;
}
//
switch (model.action) {
//
case XCardAction.Refresh:
this.detectChanges();
break;
}
});
}
private unregisterActionProvider() {
//
if (!this.ACTION_PROVIDER_SUBSCRIPTION) {
return;
}
//
this.ACTION_PROVIDER_SUBSCRIPTION.unsubscribe();
this.ACTION_PROVIDER_SUBSCRIPTION = null;
}
//#endregion
//#endregion
}