Skip to content

Commit

Permalink
Fix dynamic dialog demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Jun 12, 2023
1 parent da95c19 commit 476aee6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion api-generator/build-apidoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const staticMessages = {
interfaces: 'Defines the custom interfaces used by the module.',
types: 'Defines the custom types used by the module.',
props: 'Defines the input properties of the component.',
service: 'Defines the service used by the component',
service: 'Defines the service used by the component'
};
const app = new TypeDoc.Application();

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/treetable/treetable.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export interface TreeTableFilterOptions {
* Boolean value that defines if strict mode enabled.
*/
isStrictMode: boolean;
};
}
/**
* Defines valid templates in TreeTable.
* @group Templates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AppDocApiSection {
this._docs = this.createDocs();
}
}

getDescription(module, docName) {
if (module.description) {
return module.description;
Expand All @@ -36,7 +36,7 @@ export class AppDocApiSection {
}

isInterface(module) {
return (module.components && !Object.keys(module.components).length && Object.keys(module.interfaces).indexOf('interfaces') === -1);
return module.components && !Object.keys(module.components).length && Object.keys(module.interfaces).indexOf('interfaces') === -1;
}

createDocs() {
Expand Down Expand Up @@ -198,20 +198,18 @@ export class AppDocApiSection {
}
newDocs.push(newDoc);
}

let mergedInterfaces = [];
newDocs.forEach(doc => {
if((doc.isInterface || doc.label === 'Interfaces') && doc.children) {
doc.children.forEach(child => mergedInterfaces.push(...child.data))
}
})

let mergedInterfaces = [];
newDocs.forEach((doc) => {
if ((doc.isInterface || doc.label === 'Interfaces') && doc.children) {
doc.children.forEach((child) => mergedInterfaces.push(...child.data));
}
});

if(newDocs[0].children.find(child => child.title == 'Interfaces')) {
newDocs[0].children = newDocs[0].children.map(child => child.label === 'Interfaces' ? ({...child, data: [...child.data, ...mergedInterfaces]}) : child)
}
else {
if(mergedInterfaces.length) {
if (newDocs[0].children.find((child) => child.title == 'Interfaces')) {
newDocs[0].children = newDocs[0].children.map((child) => (child.label === 'Interfaces' ? { ...child, data: [...child.data, ...mergedInterfaces] } : child));
} else {
if (mergedInterfaces.length) {
newDocs[0].children.push({
id: `api.${this.docs[0].toLowerCase()}.interfaces`,
label: 'Interfaces',
Expand All @@ -222,26 +220,26 @@ export class AppDocApiSection {
}
}

newDocs[0].children = [...this.merge(newDocs[0].children)]
return newDocs.filter(doc => !doc.isInterface);
newDocs[0].children = [...this.merge(newDocs[0].children)];
return newDocs.filter((doc) => !doc.isInterface);
}

merge(arr) {
const mergedArray = [];
const idMap = {};

arr.forEach((element) => {
if (!idMap[element.id]) {
idMap[element.id] = element;
mergedArray.push(element);
} else {
const existingElement = idMap[element.id];
if (existingElement.data && element.data) {
existingElement.data = existingElement.data.concat(element.data);
if (!idMap[element.id]) {
idMap[element.id] = element;
mergedArray.push(element);
} else {
const existingElement = idMap[element.id];
if (existingElement.data && element.data) {
existingElement.data = existingElement.data.concat(element.data);
}
}
}
});

return mergedArray;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class AppDocSectionNavComponent implements OnInit, OnDestroy {
}, 50);
}
}

onButtonClick(doc) {
this.activeId = doc.id;
setTimeout(() => {
Expand Down Expand Up @@ -108,7 +108,7 @@ export class AppDocSectionNavComponent implements OnInit, OnDestroy {
}

getActiveChildId(activeId, childId) {
return activeId.toLowerCase().includes(childId.toLowerCase())
return activeId.toLowerCase().includes(childId.toLowerCase());
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<app-doc title="Angular Dynamic Dialog Component" header="Dynamic Dialog" description="Dialogs can be created dynamically with any component as the content using a DialogService." [docs]="docs" [apiDocs]="['DynamicDialog', 'Dialog', 'DynamicDialog-Ref', 'DynamicDialog-Config']"></app-doc>
<app-doc title="Angular Dynamic Dialog Component" header="Dynamic Dialog" description="Dialogs can be created dynamically with any component as the content using a DialogService." [docs]="docs" [apiDocs]="['Dialog', 'DynamicDialog-Config', 'DynamicDialog-Ref']"></app-doc>

0 comments on commit 476aee6

Please sign in to comment.