frontend code clean up

This commit is contained in:
amentis 2024-07-10 11:52:12 +03:00
parent 914e22c8ed
commit b026dbb4a5
13 changed files with 1 additions and 71 deletions

View File

@ -4,8 +4,6 @@ export enum AppRole {
User = "User", User = "User",
TenantAdmin = "TenantAdmin", TenantAdmin = "TenantAdmin",
TenantUser = "TenantUser", TenantUser = "TenantUser",
// TenantManager = "TenantManager",
// TenantDescriptionTemplateEditor = "TenantDescriptionTemplateEditor"
TenantPlanManager = "TenantPlanManager", TenantPlanManager = "TenantPlanManager",
TenantConfigManager = "TenantConfigManager" TenantConfigManager = "TenantConfigManager"
} }

View File

@ -1,14 +1,8 @@
export enum PlanBlueprintSystemFieldType { export enum PlanBlueprintSystemFieldType {
Title = 0, Title = 0,
Description = 1, Description = 1,
// RESEARCHERS = 2,
// ORGANIZATIONS = 3,
Language = 2, Language = 2,
Contact = 3, Contact = 3,
// FUNDER = 6,
// GRANT = 7,
// PROJECT = 8,
// LICENSE = 9,
AccessRights = 4, AccessRights = 4,
User = 5 User = 5
} }

View File

@ -6,7 +6,7 @@ export interface PreprocessingDescriptionModel {
label: string; label: string;
} }
// rda config // common config
export interface DescriptionCommonModelConfig { export interface DescriptionCommonModelConfig {
id: string; id: string;
sectionId: Guid; sectionId: Guid;

View File

@ -36,11 +36,6 @@ export class ReferenceService {
return this.http.post<QueryResult<Reference>>(url, q).pipe(catchError((error: any) => throwError(error))); return this.http.post<QueryResult<Reference>>(url, q).pipe(catchError((error: any) => throwError(error)));
} }
// search(q: ReferenceSearchLookup): Observable<Reference[]> {
// const url = `${this.apiBase}/search`;
// return this.http.post<Reference[]>(url, q).pipe(catchError((error: any) => throwError(error)));
// }
searchWithDefinition(q: ReferenceSearchDefinitionLookup): Observable<Reference[]> { searchWithDefinition(q: ReferenceSearchDefinitionLookup): Observable<Reference[]> {
const url = `${this.apiBase}/search`; const url = `${this.apiBase}/search`;
return this.http.post<Reference[]>(url, q).pipe(catchError((error: any) => throwError(error))); return this.http.post<Reference[]>(url, q).pipe(catchError((error: any) => throwError(error)));

View File

@ -120,22 +120,12 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit
} }
// private _findParentSection():FormGroup{
// const parent = this.form.parent;
// return parent;
// }
private initialize() { private initialize() {
if (this.tocentry.type === ToCEntryType.Section) { if (this.tocentry.type === ToCEntryType.Section) {
this.form = this.tocentry.form; this.form = this.tocentry.form;
this.numbering = this.tocentry.numbering; this.numbering = this.tocentry.numbering;
this._selectedFieldSetId = null; this._selectedFieldSetId = null;
// this.scroller.next(null);
this._scrollOnTop(true); this._scrollOnTop(true);
} else if (this.tocentry.type === ToCEntryType.FieldSet) { } else if (this.tocentry.type === ToCEntryType.FieldSet) {
this.form = this.tocentry.form.parent.parent; this.form = this.tocentry.form.parent.parent;
@ -144,11 +134,9 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit
numberingArray.splice(numberingArray.length - 1); numberingArray.splice(numberingArray.length - 1);
this.numbering = numberingArray.join('.'); this.numbering = numberingArray.join('.');
} else { } else {
// console.warn('!not found numbering');
} }
this._selectedFieldSetId = this.tocentry.id; this._selectedFieldSetId = this.tocentry.id;
// this._scrollToElement(this.selectedFieldSetId);
this.scroller.next(this.tocentry.id); this.scroller.next(this.tocentry.id);
} else {//scroll on top } else {//scroll on top
// this._scrollOnTop(); // this._scrollOnTop();
@ -226,7 +214,6 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit
parentArray.insert(index, fieldsetForm); parentArray.insert(index, fieldsetForm);
this.dataNeedsRefresh.emit(); this.dataNeedsRefresh.emit();
// this.selectedFieldSetId = fieldSetId;
setTimeout(() => { setTimeout(() => {
this.selectedFieldSetId = fieldSetId; this.selectedFieldSetId = fieldSetId;
}, 200); }, 200);

View File

@ -703,10 +703,8 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
page.id = Guid.create().toString(); page.id = Guid.create().toString();
if (isNaN(pages.length)) { page.ordinal = 0; } else { page.ordinal = pages.length; } if (isNaN(pages.length)) { page.ordinal = 0; } else { page.ordinal = pages.length; }
const pageForm = page.buildForm({ rootPath: 'definition.pages[' + pages.length + '].' }); const pageForm = page.buildForm({ rootPath: 'definition.pages[' + pages.length + '].' });
// this.dataModel.pages.push(page);
pages.push(pageForm); pages.push(pageForm);
// this.form.updateValueAndValidity();
this.refreshToCEntries(); this.refreshToCEntries();
this.selectedTocEntry = this._findTocEntryById(pageForm.get('id').value, this.toCEntries); this.selectedTocEntry = this._findTocEntryById(pageForm.get('id').value, this.toCEntries);
@ -739,7 +737,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
} }
sectionsArray.push(section.buildForm({ rootPath: 'definition.pages[' + pageIndex + '].sections[' + sectionsArray.length + '].' })); sectionsArray.push(section.buildForm({ rootPath: 'definition.pages[' + pageIndex + '].sections[' + sectionsArray.length + '].' }));
// this.form.updateValueAndValidity();
} else if (parent.type == ToCEntryType.Section) { //SUBSECTION OF SECTION } else if (parent.type == ToCEntryType.Section) { //SUBSECTION OF SECTION
let sectionIndexes: number[] = []; let sectionIndexes: number[] = [];
@ -768,7 +765,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
} }
sectionsArray.push(section.buildForm({ rootPath: 'definition.pages[' + pageIndex + '].' + parentSectionRootPath + 'sections[' + sectionsArray.length + '].' })); sectionsArray.push(section.buildForm({ rootPath: 'definition.pages[' + pageIndex + '].' + parentSectionRootPath + 'sections[' + sectionsArray.length + '].' }));
// (child.form.parent as FormArray).push(section.buildForm());
} }
} else { } else {
@ -777,8 +773,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
const sectionAdded = sectionsArray.at(sectionsArray.length - 1) as UntypedFormGroup; const sectionAdded = sectionsArray.at(sectionsArray.length - 1) as UntypedFormGroup;
// sectionAdded.setValidators(this.customEditorValidators.sectionHasAtLeastOneChildOf('fieldSets','sections'));
// sectionAdded.updateValueAndValidity();
this.refreshToCEntries(); this.refreshToCEntries();
@ -829,7 +823,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
this.refreshToCEntries(); this.refreshToCEntries();
this.selectedTocEntry = this._findTocEntryById(fieldSetId.toString(), this.toCEntries); this.selectedTocEntry = this._findTocEntryById(fieldSetId.toString(), this.toCEntries);
// fieldForm.updateValueAndValidity();
break; break;
} }
@ -1051,7 +1044,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
if (this.selectedTocEntry) { if (this.selectedTocEntry) {
//.find(e => e.id)
if (this.tocEntryIsChildOf(this.selectedTocEntry, tce)) { if (this.tocEntryIsChildOf(this.selectedTocEntry, tce)) {
if (this.selectedTocEntry.type == ToCEntryType.Page) { if (this.selectedTocEntry.type == ToCEntryType.Page) {
this.selectedTocEntry = null; this.selectedTocEntry = null;
@ -1059,13 +1051,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
const pages = this.formGroup.get('definition').get('pages') as UntypedFormArray; const pages = this.formGroup.get('definition').get('pages') as UntypedFormArray;
//if first level section //if first level section
// const firstLevelSections = (this.formGroup.get('definition').get('sections') as UntypedFormArray);
// let isFirstLevel: boolean = false;
// firstLevelSections.controls.forEach(section => {
// if (section.get('id').value === tce.id) {
// isFirstLevel = true;
// }
// });
let isFirstLevel: boolean = false; let isFirstLevel: boolean = false;
for (let j = 0; j < pages.length; j++) { for (let j = 0; j < pages.length; j++) {
@ -1190,7 +1175,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
const aValue = a.form.get('ordinal').value as number; const aValue = a.form.get('ordinal').value as number;
const bValue = b.form.get('ordinal').value as number; const bValue = b.form.get('ordinal').value as number;
// if(!aValue || !bValue) return 0;
return aValue - bValue; return aValue - bValue;
} }
private _updateNumbering(entries: ToCEntry[], parentNumbering: string) { private _updateNumbering(entries: ToCEntry[], parentNumbering: string) {
@ -1261,7 +1245,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
} }
get progressStyle() { get progressStyle() {
// return {'transform': 'translateX('+this.barPercentage+'%) skewX(-25deg)'}
const diff = 3; const diff = 3;
return { return {

View File

@ -306,7 +306,6 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements
}); });
if (indx >= 0) { if (indx >= 0) {
// e.form.get('ordinal').setValue(i+1);
targetContainer.subEntries.filter(e => e.form?.get('ordinal').value >= position).forEach(e => { targetContainer.subEntries.filter(e => e.form?.get('ordinal').value >= position).forEach(e => {
const ordinal = e.form.get('ordinal'); const ordinal = e.form.get('ordinal');
const updatedOrdinalVal = ordinal?.value + 1; const updatedOrdinalVal = ordinal?.value + 1;

View File

@ -241,7 +241,6 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
) )
fieldForm.markAsDirty(); fieldForm.markAsDirty();
// this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), fieldCode);
if (this.formGroup.get('definition').get('getEnabled').value == true) this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), fieldCode); if (this.formGroup.get('definition').get('getEnabled').value == true) this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), fieldCode);
else this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), fieldCode); else this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), fieldCode);
} }
@ -252,7 +251,6 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
if (fieldsFormArray.valid) { if (fieldsFormArray.valid) {
for (let i = 0; i < fieldsFormArray.length; i++) { for (let i = 0; i < fieldsFormArray.length; i++) {
const code = fieldsFormArray.at(i).get('code').value; const code = fieldsFormArray.at(i).get('code').value;
// this.addFieldMapping(code, "searchConfiguration");
if (this.formGroup.get('definition').get('getEnabled').value == true) { if (this.formGroup.get('definition').get('getEnabled').value == true) {
this.addFieldMapping(code, "getConfiguration"); this.addFieldMapping(code, "getConfiguration");
this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), code); this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), code);
@ -285,7 +283,6 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
const fieldsMapping = new ResultFieldsMappingConfigurationEditorModel(this.editorModel.validationErrorModel); const fieldsMapping = new ResultFieldsMappingConfigurationEditorModel(this.editorModel.validationErrorModel);
fieldsMapping.code = code; fieldsMapping.code = code;
formArray.push(fieldsMapping.buildForm({ rootPath: "definition." + controlName + ".results.fieldsMapping[" + fieldMappingSize + "]." })); formArray.push(fieldsMapping.buildForm({ rootPath: "definition." + controlName + ".results.fieldsMapping[" + fieldMappingSize + "]." }));
// formArray.at(fieldMappingSize).get('code').patchValue(code);
} }
removeFieldMapping(baseFormGroup: any, fieldCode: string) { removeFieldMapping(baseFormGroup: any, fieldCode: string) {

View File

@ -128,7 +128,6 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
this.description = data; this.description = data;
this.description.plan.planUsers = data.plan.planUsers.filter(x => x.isActive === IsActive.Active); this.description.plan.planUsers = data.plan.planUsers.filter(x => x.isActive === IsActive.Active);
this.researchers = this.referenceService.getReferencesForTypes(this.description?.plan?.planReferences, [this.referenceTypeService.getResearcherReferenceType()]); this.researchers = this.referenceService.getReferencesForTypes(this.description?.plan?.planReferences, [this.referenceTypeService.getResearcherReferenceType()]);
// this.users = this.description.plan.users;
this.checkLockStatus(this.description.id); this.checkLockStatus(this.description.id);
this.canDelete = (this.authService.hasPermission(AppPermission.DeleteDescription) || this.canDelete = (this.authService.hasPermission(AppPermission.DeleteDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.DeleteDescription)) && this.description.belongsToCurrentTenant != false; this.description.authorizationFlags?.some(x => x === AppPermission.DeleteDescription)) && this.description.belongsToCurrentTenant != false;
@ -144,10 +143,6 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
this.canInvitePlanUsers = (this.authService.hasPermission(AppPermission.InvitePlanUsers) || this.canInvitePlanUsers = (this.authService.hasPermission(AppPermission.InvitePlanUsers) ||
this.description.authorizationFlags?.some(x => x === AppPermission.InvitePlanUsers)) && this.description.belongsToCurrentTenant != false; this.description.authorizationFlags?.some(x => x === AppPermission.InvitePlanUsers)) && this.description.belongsToCurrentTenant != false;
// const breadCrumbs = [];
// breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DESCRIPTION-DESCRIPTIONS'), url: "/descriptions" });
// breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/' + this.description.id });
// this.breadCrumbs = observableOf(breadCrumbs);
}, (error: any) => { }, (error: any) => {
this.httpErrorHandlingService.handleBackedRequestError(error); this.httpErrorHandlingService.handleBackedRequestError(error);
@ -172,11 +167,6 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
this.description = data; this.description = data;
this.researchers = this.referenceService.getReferencesForTypes(this.description?.plan?.planReferences, [this.referenceTypeService.getResearcherReferenceType()]); this.researchers = this.referenceService.getReferencesForTypes(this.description?.plan?.planReferences, [this.referenceTypeService.getResearcherReferenceType()]);
// this.users = this.description.plan.users;
// const breadCrumbs = [];
// breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DESCRIPTIONS'), url: "/explore" });
// breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/public/' + this.description.id });
// this.breadCrumbs = observableOf(breadCrumbs);
}, (error: any) => { }, (error: any) => {
this.httpErrorHandlingService.handleBackedRequestError(error); this.httpErrorHandlingService.handleBackedRequestError(error);

View File

@ -146,11 +146,6 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit {
} }
this.selectedPlanVersion = this.plan; this.selectedPlanVersion = this.plan;
this.checkLockStatus(this.plan.id); this.checkLockStatus(this.plan.id);
// this.setIsUserOwner();
// const breadCrumbs = [];
// breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-PLANS'), url: "/plans" });
// breadCrumbs.push({ parentComponentName: 'PlanListingComponent', label: this.plan.label, url: '/plans/overview/' + this.plan.id });
// this.breadCrumbs = observableOf(breadCrumbs);
}, (error: any) => { }, (error: any) => {
this.httpErrorHandlingService.handleBackedRequestError(error); this.httpErrorHandlingService.handleBackedRequestError(error);

View File

@ -109,10 +109,6 @@ export class PlanEditorModel extends BaseEditorModel implements PlanPersist {
(item, index) => descriptionTemplatesFormGroup.addControl(item.toString(), (item, index) => descriptionTemplatesFormGroup.addControl(item.toString(),
new FormControl(this.descriptionTemplates?.filter(x => x.sectionId === item)?.filter(x => x.descriptionTemplateGroupId).map(x => x.descriptionTemplateGroupId) || [], context.getValidation('descriptionTemplates').validators)) new FormControl(this.descriptionTemplates?.filter(x => x.sectionId === item)?.filter(x => x.descriptionTemplateGroupId).map(x => x.descriptionTemplateGroupId) || [], context.getValidation('descriptionTemplates').validators))
); );
// // buildForm({
// // rootPath: `descriptionTemplates[${index}].`
// })), //context.getValidation('descriptionTemplates')
// ))
if (disabled) descriptionTemplatesFormGroup.disable(); if (disabled) descriptionTemplatesFormGroup.disable();
formGroup.addControl('descriptionTemplates', descriptionTemplatesFormGroup); formGroup.addControl('descriptionTemplates', descriptionTemplatesFormGroup);

View File

@ -1,9 +1,7 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
// import { PlanWizardComponent } from './description-wizard/description-wizard.component';
import { AppPermission } from '@app/core/common/enum/permission.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum';
import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service'; import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service';
// import { PlanOverviewComponent } from './overview/description-overview.component';
import { AuthGuard } from '@app/core/auth-guard.service'; import { AuthGuard } from '@app/core/auth-guard.service';
import { PlanEditorComponent } from './plan-editor.component'; import { PlanEditorComponent } from './plan-editor.component';
import { PlanEditorEntityResolver } from './resolvers/plan-editor-enitity.resolver'; import { PlanEditorEntityResolver } from './resolvers/plan-editor-enitity.resolver';

View File

@ -2,8 +2,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonFormsModule } from '@common/forms/common-forms.module'; import { CommonFormsModule } from '@common/forms/common-forms.module';
import { CommonUiModule } from '@common/ui/common-ui.module'; import { CommonUiModule } from '@common/ui/common-ui.module';
import { CoreNotificationServiceModule } from '@notification-service/services/core-service.module';
// import { TotpModule } from '@idp-service/ui/totp/totp.module';
import { NotifierListEditorComponent } from './notifier-list-editor.component'; import { NotifierListEditorComponent } from './notifier-list-editor.component';
@NgModule({ @NgModule({