Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/setup wizard public forms #2682

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import { AdminModule } from "./core/admin/admin.module";
import { Logging } from "./core/logging/logging.service";
import { APP_INITIALIZER_DEMO_DATA } from "./core/demo-data/demo-data.app-initializer";
import { TemplateExportModule } from "./features/template-export/template-export.module";
import { PubliFormModule } from "./features/public-form/public-form.module";

/**
* Main entry point of the application.
Expand Down Expand Up @@ -132,6 +133,7 @@ import { TemplateExportModule } from "./features/template-export/template-export
TodosModule,
AdminModule,
TemplateExportModule,
PubliFormModule,
// top level component
UiComponent,
// Global Angular Material modules
Expand Down
22 changes: 18 additions & 4 deletions src/app/features/public-form/public-form-config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import { Entity } from "../../core/entity/model/entity";
import { DatabaseEntity } from "../../core/entity/database-entity.decorator";
import { DatabaseField } from "../../core/entity/database-field.decorator";
import { LongTextDatatype } from "app/core/basic-datatypes/string/long-text.datatype";
import { FieldGroup } from "app/core/entity-details/form/field-group";

@DatabaseEntity("PublicFormConfig")
export class PublicFormConfig extends Entity {
@DatabaseField() title: string;
@DatabaseField() description: string;
@DatabaseField() entity: string;
@DatabaseField() columns: FieldGroup[];
static override label = $localize`:PublicFormConfig:Public Form`;
static override labelPlural = $localize`:PublicFormConfig:Public Forms`;
static override route = "admin/public-forms";

@DatabaseField({
label: $localize`:PublicFormConfig:Title`,
}) title: string;
@DatabaseField({
label: $localize`:PublicFormConfig:Description`,
dataType: LongTextDatatype.dataType
}) description: string;
@DatabaseField({
label: $localize`:PublicFormConfig:Entity`,
}) entity: string;
@DatabaseField({
label: $localize`:PublicFormConfig:Columns`,
isArray: true,
}) columns: FieldGroup[];
/** @deprecated use ColumnConfig directly in the columns array instead */
@DatabaseField() prefilled: { [key in string]: any };
}
1 change: 1 addition & 0 deletions src/app/features/public-form/public-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class PublicFormComponent<E extends Entity> implements OnInit {
private async loadFormConfig() {
const id = this.route.snapshot.paramMap.get("id");
this.formConfig = await this.entityMapper.load(PublicFormConfig, id);
console.log(await this.entityMapper.loadType(PublicFormConfig),"nanannanana")
this.entityType = this.entities.get(
this.formConfig.entity,
) as EntityConstructor<E>;
Expand Down
85 changes: 85 additions & 0 deletions src/app/features/public-form/public-form.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { AsyncComponent, ComponentRegistry } from "../../dynamic-components";
import { RouterService } from "../../core/config/dynamic-routing/router.service";
import { ViewConfig } from "../../core/config/dynamic-routing/view-config.interface";
import { EntityDetailsConfig } from "../../core/entity-details/EntityDetailsConfig";
import { EntityListConfig } from "../../core/entity-list/EntityListConfig";
import { AdminOverviewService } from "../../core/admin/admin-overview/admin-overview.service";
import { EntityActionsMenuService } from "../../core/entity-details/entity-actions-menu/entity-actions-menu.service";
import { DefaultDatatype } from "../../core/entity/default-datatype/default.datatype";
import { TemplateExportFileDatatype } from "../template-export/template-export-file-datatype/template-export-file.datatype";
import { PublicFormConfig } from "./public-form-config";

/**
* Manage template files with placeholders that can be used to render files for export of entities.
*/
@NgModule({
declarations: [],
imports: [CommonModule],

})
export class PubliFormModule {
static databaseEntities = [PublicFormConfig];

constructor(
components: ComponentRegistry,
routerService: RouterService,
adminOverviewService: AdminOverviewService,
entityActionsMenuService: EntityActionsMenuService,
) {
routerService.addRoutes(viewConfigs);
console.log(PublicFormConfig.ENTITY_TYPE,"PublicFormConfig.ENTITY_TYPE")


adminOverviewService.menuItems.push({
label: $localize`:admin menu item:Manage Public forms`,
link: PublicFormConfig.route,
});
}
}


const viewConfigs: ViewConfig[] = [
// List View
{

_id: "view:" + PublicFormConfig.route,
component: "EntityList",
config: {
entityType: PublicFormConfig.ENTITY_TYPE,
columns: ["title", "description", "entity", "columns"],
filters: [{ id: "entity" }],
} as EntityListConfig,
},

// Details View
{
_id: "view:" + PublicFormConfig.route + "/:id",
component: "EntityDetails",
config: {
entityType: PublicFormConfig.ENTITY_TYPE,
panels: [
{
components: [
{
component: "Form",
config: {
fieldGroups: [
{
fields: [
"title",
"description",
"entity",
"columns"
],
}
],
},
},
],
},
],
} as EntityDetailsConfig,
},
];
Loading