Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import { ButtonModule, SnackbarService, TooltipModule } from '@oort-front/ui';
import { DialogModule, AlertModule } from '@oort-front/ui';
import { renderGlobalProperties } from '../../../survey/render-global-properties';
import { ReferenceDataService } from '../../../services/reference-data/reference-data.service';
import { FormHelpersService } from '../../../services/form-helper/form-helper.service';
import {
FormHelpersService,
QuestionType,
} from '../../../services/form-helper/form-helper.service';
import { Question } from '../../../survey/types';
import 'survey-core/survey.i18n.min.js';
import {
CustomJSONEditorComponent,
SurveyCustomJSONEditorPlugin,
} from '../../form-builder/custom-json-editor/custom-json-editor.component';
import { SurveyCustomJSONEditorPlugin } from '../../form-builder/custom-json-editor/custom-json-editor.component';
import { updateModalChoicesAndValue } from '../../../survey/global-properties/reference-data';
import { HttpClient } from '@angular/common/http';
//import 'survey-creator-core/survey-creator-core.i18n.min.js';
Expand All @@ -46,26 +46,26 @@ const DEFAULT_STRUCTURE = {
* Commented types are not yet implemented.
*/
const QUESTION_TYPES = [
'text',
'checkbox',
'radiogroup',
'dropdown',
'tagbox',
'comment',
QuestionType.TEXT,
QuestionType.CHECKBOX,
QuestionType.RADIO_GROUP,
QuestionType.DROPDOWN,
QuestionType.TAGBOX,
QuestionType.COMMENT,
// 'rating',
// 'ranking',
// 'imagepicker',
'boolean',
QuestionType.BOOLEAN,
// 'image',
'html',
QuestionType.HTML,
// 'signaturepad',
// 'expression',
// 'matrix',
// 'matrixdropdown',
// 'matrixdynamic',
// 'multipletext',
'panel',
'paneldynamic',
QuestionType.PANEL,
QuestionType.PANEL_DYNAMIC,
];

/**
Expand Down Expand Up @@ -170,7 +170,6 @@ const CORE_QUESTION_ALLOWED_PROPERTIES = [
AlertModule,
SurveyCreatorModule,
ButtonModule,
CustomJSONEditorComponent,
],
})
export class FilterBuilderModalComponent
Expand Down
15 changes: 13 additions & 2 deletions libs/shared/src/lib/components/email/constant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { QuestionType } from './../../services/form-helper/form-helper.service';

/** Select field types */
export const selectFieldTypes = ['select', 'dropdown', 'checkbox', 'tagbox'];
export const selectFieldTypes = [
QuestionType.SELECT,
QuestionType.DROPDOWN,
QuestionType.CHECKBOX,
QuestionType.TAGBOX,
];
/**
* Regex for valid strings in layout page select
*/
Expand All @@ -11,4 +18,8 @@ export const emailRegex =
/**
* Array for missing types
*/
export const missingTypesArray = ['matrix', 'matrixdynamic', 'matrixdropdown'];
export const missingTypesArray = [
QuestionType.MATRIX,
QuestionType.MATRIX_DYNAMIC,
QuestionType.MATRIX_DROPDOWN,
];
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import {
} from 'survey-core';
import { SurveyCreatorModel } from 'survey-creator-core';
import { Form } from '../../models/form.model';
import { FormHelpersService } from '../../services/form-helper/form-helper.service';
import {
FormHelpersService,
QuestionType,
} from '../../services/form-helper/form-helper.service';
import { ReferenceDataService } from '../../services/reference-data/reference-data.service';
import { updateModalChoicesAndValue } from '../../survey/global-properties/reference-data';
import { renderGlobalProperties } from '../../survey/render-global-properties';
Expand All @@ -37,27 +40,27 @@ import { SurveyCustomJSONEditorPlugin } from './custom-json-editor/custom-json-e
* Commented types are not yet implemented.
*/
const QUESTION_TYPES = [
'text',
'checkbox',
'radiogroup',
'dropdown',
'tagbox',
'comment',
// 'rating',
// 'ranking',
// 'imagepicker',
'boolean',
'image',
'html',
// 'signaturepad',
'expression',
'file',
'matrix',
'matrixdropdown',
'matrixdynamic',
'multipletext',
'panel',
'paneldynamic',
QuestionType.TEXT,
QuestionType.CHECKBOX,
QuestionType.RADIO_GROUP,
QuestionType.DROPDOWN,
QuestionType.TAGBOX,
QuestionType.COMMENT,
// 'RATING,
// 'RANKING,
// 'IMAGEPICKER,
QuestionType.BOOLEAN,
QuestionType.IMAGE,
QuestionType.HTML,
// 'SIGNATUREPAD,
QuestionType.EXPRESSION,
QuestionType.FILE,
QuestionType.MATRIX,
QuestionType.MATRIX_DROPDOWN,
QuestionType.MATRIX_DYNAMIC,
QuestionType.MULTIPLE_TEXT,
QuestionType.PANEL,
QuestionType.PANEL_DYNAMIC,
];

/**
Expand Down Expand Up @@ -542,7 +545,7 @@ export class FormBuilderComponent
question.choices = [];
}
}
if (question.getType() === 'multipletext') {
if (question.getType() === QuestionType.MULTIPLE_TEXT) {
let validQuestion = true;
// Check if every item of the questions is valid, otherwise stop loop and function
question.items.every((item: any) => {
Expand All @@ -569,7 +572,7 @@ export class FormBuilderComponent
return false;
}
}
if (question.getType() === 'matrix') {
if (question.getType() === QuestionType.MATRIX) {
question.columns.forEach((x: any) => {
x.text = x.text || x.value || x;
x.value = this.formHelpersService.toSnakeCase(x.value || x.text || x);
Expand All @@ -579,7 +582,7 @@ export class FormBuilderComponent
x.value = this.formHelpersService.toSnakeCase(x.value || x.text || x);
});
}
if (question.getType() === 'matrixdropdown') {
if (question.getType() === QuestionType.MATRIX_DROPDOWN) {
question.columns.forEach((x: any) => {
x.title = x.title || x.name || x;
x.name = this.formHelpersService.toSnakeCase(x.name || x.title || x);
Expand All @@ -589,7 +592,10 @@ export class FormBuilderComponent
x.value = this.formHelpersService.toSnakeCase(x.value || x.text || x);
});
}
if (['resource', 'resources'].includes(question.getType())) {
if (
question.getType() === QuestionType.RESOURCE ||
question.getType() === QuestionType.RESOURCES
) {
if (question.relatedName) {
question.relatedName = this.formHelpersService.toSnakeCase(
question.relatedName
Expand Down Expand Up @@ -664,7 +670,10 @@ export class FormBuilderComponent
}
}
// Check that at least an application is selected in the properties of users and owner question
if (['users', 'owner'].includes(question.getType())) {
if (
question.getType() === QuestionType.USERS ||
question.getType() === QuestionType.OWNER
) {
if (!question.applications) {
this.snackBar.openSnackBar(
this.translate.instant('pages.formBuilder.errors.selectApplication', {
Expand Down
17 changes: 9 additions & 8 deletions libs/shared/src/lib/components/form/form-examples.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ResizeBatchService } from '@progress/kendo-angular-common';
import { IconsService } from '@progress/kendo-angular-icons';
import { ComponentCollection, CustomWidgetCollection } from 'survey-core';
import { DateInputsModule } from '@progress/kendo-angular-dateinputs';
import { QuestionType } from '../../services/form-helper/form-helper.service';

// You can create new stories getting the logic from: https://surveyjs.io/create-free-survey

Expand Down Expand Up @@ -173,14 +174,14 @@ export const MultiPages: Story = {
elements: [
{
title: 'Dropdown',
type: 'dropdown',
type: QuestionType.DROPDOWN,
name: 'question1',
...sharedQuestion(args),
choices: ['Item 1', 'Item 2', 'Item 3'],
},
{
title: 'Radiogroup',
type: 'radiogroup',
type: QuestionType.RADIO_GROUP,
name: 'question2',
...sharedQuestion(args),
choices: ['Item a', 'Item b', 'Item c'],
Expand All @@ -192,7 +193,7 @@ export const MultiPages: Story = {
elements: [
{
title: 'Yes/No',
type: 'boolean',
type: QuestionType.BOOLEAN,
name: 'question1',
...sharedQuestion(args),
},
Expand All @@ -203,7 +204,7 @@ export const MultiPages: Story = {
elements: [
{
title: 'Date',
type: 'text',
type: QuestionType.TEXT,
name: 'question1',
inputType: 'date',
...sharedQuestion(args),
Expand Down Expand Up @@ -236,7 +237,7 @@ export const Logic: Story = {
elements: [
{
title: 'Dropdown',
type: 'dropdown',
type: QuestionType.DROPDOWN,
name: 'question1',
description:
'Question 2 only will appears if the selected option is Item 1',
Expand All @@ -245,7 +246,7 @@ export const Logic: Story = {
},
{
title: 'Date',
type: 'text',
type: QuestionType.TEXT,
name: 'question2',
inputType: 'date',
visible: false,
Expand Down Expand Up @@ -283,15 +284,15 @@ export const DefaultValue: Story = {
{
title: 'Number',
defaultValue: 10,
type: 'text',
type: QuestionType.TEXT,
name: 'question1',
inputType: 'number',
...sharedQuestion(args),
},
{
title: 'Text',
defaultValue: 'Default value',
type: 'text',
type: QuestionType.TEXT,
name: 'question2',
inputType: 'text',
...sharedQuestion(args),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { QuestionType } from '../../../../services/form-helper/form-helper.service';
import {
FormInputStoryMeta,
DefaultFormInputStory,
Expand All @@ -14,7 +15,7 @@ const questionName = 'Dropdown question';

/** Base question */
const baseQuestion = {
type: 'dropdown',
type: QuestionType.DROPDOWN,
choices: ['Item 1', 'Item 2', 'Item 3'],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { SeriesMappingModule } from './series-mapping.module';
import { StorybookTranslateModule } from '../../../storybook-translate/storybook-translate-module';
import { createMappingForm } from '../aggregation-builder-forms';
import { delay } from 'rxjs/operators';
import {
InputType,
QuestionType,
} from '../../../../services/form-helper/form-helper.service';

export default {
component: SeriesMappingComponent,
Expand All @@ -31,7 +35,7 @@ export default {
*/
const DEFAULT_FIELDS = [
{
type: 'tagbox',
type: QuestionType.TAGBOX,
name: 'affected_countriees',
isRequired: false,
readOnly: false,
Expand All @@ -44,15 +48,15 @@ const DEFAULT_FIELDS = [
},
},
{
type: 'tagbox',
type: QuestionType.TAGBOX,
name: 'regions',
isRequired: false,
readOnly: false,
isCore: true,
choices: ['AFR', 'AMR', 'WMR', 'EUR', 'SEAR', 'WPR'],
},
{
type: 'dropdown',
type: QuestionType.DROPDOWN,
name: 'disease',
isRequired: false,
readOnly: false,
Expand All @@ -65,21 +69,21 @@ const DEFAULT_FIELDS = [
},
},
{
type: 'text',
type: QuestionType.TEXT,
name: 'title',
isRequired: false,
readOnly: false,
isCore: true,
},
{
type: 'text',
type: QuestionType.TEXT,
name: 'description',
isRequired: false,
readOnly: false,
isCore: true,
},
{
type: 'resources',
type: QuestionType.RESOURCES,
name: 'sources',
isRequired: false,
readOnly: false,
Expand Down Expand Up @@ -125,20 +129,20 @@ const DEFAULT_FIELDS = [
},
},
{
type: 'date',
type: InputType.DATE,
name: 'date',
isRequired: false,
readOnly: false,
isCore: true,
},
{
type: 'text',
type: QuestionType.TEXT,
name: 'follow_comment',
isCore: true,
generated: true,
},
{
type: 'radiogroup',
type: QuestionType.RADIO_GROUP,
name: 'follow',
isRequired: false,
readOnly: false,
Expand Down
Loading
Loading