Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
47dbb83
working as users
TaiKamilla Sep 4, 2023
128df74
working as people
TaiKamilla Sep 4, 2023
08a7cbc
Merge branch '2.1.x' into feat/AB#74292_ABC-Create-people-picker-ques…
NathanHGit Sep 6, 2023
b9e6263
merge beta
MwanPygmay Sep 26, 2023
8767a34
added support for people question in grids and summary cards, and rep…
MwanPygmay Sep 27, 2023
18ada65
Merge branch 'beta' into feat/AB#74292_ABC-Create-people-picker-quest…
TaiKamilla Oct 4, 2023
41ae038
clean up after beta merge
TaiKamilla Oct 4, 2023
e922878
new naming
TaiKamilla Oct 6, 2023
9a72c60
remove console.log
TaiKamilla Oct 6, 2023
bc4147e
It works
TaiKamilla Oct 9, 2023
8028c98
cleaner
TaiKamilla Oct 9, 2023
41bedaf
remove unnecessary queries
TaiKamilla Oct 9, 2023
9f2883a
Merge branch '2.x.x' into feat/AB#74292_ABC-Create-people-picker-ques…
NathanHGit Mar 20, 2024
ac20a54
feat: add people id and fix minor issues
NathanHGit Mar 20, 2024
8610c0c
feat: add people dropdown
NathanHGit Mar 22, 2024
f936fbd
feat: handle people filtering
NathanHGit Mar 25, 2024
57b7932
load people choices on grid update
NathanHGit Mar 27, 2024
ab46147
fix empty value and wrong column width
NathanHGit Mar 27, 2024
7274101
handle two-word search
NathanHGit Mar 29, 2024
bc3cf28
changed number of search char to be 2
MwanPygmay Apr 17, 2024
85a5e3f
Merge branch '2.x.x' into feat/AB#74292_ABC-Create-people-picker-ques…
AntoineRelief Apr 24, 2024
40816f2
add safeguard in widget service
AntoineRelief Apr 24, 2024
3044f78
add placeholder to people picker
AntoineRelief Apr 25, 2024
dfc388f
now fetching records ten by ten + start of single picker
MwanPygmay Apr 30, 2024
c780b7e
now support seeing details in grid
MwanPygmay May 2, 2024
2ddb3ed
renaming + add support in grids
MwanPygmay May 3, 2024
494c027
add support for summary cards and editor
MwanPygmay May 3, 2024
c9284de
improve a bit hasNextPage
MwanPygmay May 3, 2024
061ed6a
now loading waits for metaquery
MwanPygmay May 3, 2024
d103daa
add support for filter
MwanPygmay May 6, 2024
0e9bf5b
refactor
MwanPygmay May 17, 2024
8201aaf
Merge branch '2.x.x' into feat/AB#74292_ABC-Create-people-picker-ques…
AntoineRelief Jun 14, 2024
5f25625
disable meta data loading in summary card if not needed
AntoineRelief Jun 14, 2024
796f297
merge 2.x.x
MwanPygmay Jun 27, 2024
02401ea
add support for filters, add support in grids for singlepeople
MwanPygmay Jun 27, 2024
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 @@ -751,7 +751,7 @@
</div>
</ng-template>
</kendo-grid-column>
<!-- MULTI SELECT QUESTION TYPES ( checkbox / tagbox / owner / users ) -->
<!-- MULTI SELECT QUESTION TYPES ( checkbox / tagbox / owner / users / people ) -->
<kendo-grid-column
*ngIf="
field.type === 'JSON' && multiSelectTypes.includes(field.meta.type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const MULTISELECT_TYPES: string[] = [
'tagbox',
'owner',
'users',
'people',
];

/** Settings for pager */
Expand Down
8 changes: 8 additions & 0 deletions libs/shared/src/lib/models/people.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** Model for Person object. */
export interface Person {
id?: string;
firstName?: string;
lastName?: string;
username?: string;
email?: string;
}
92 changes: 92 additions & 0 deletions libs/shared/src/lib/survey/components/people.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { Apollo } from 'apollo-angular';
import * as SurveyCreator from 'survey-creator';
import { DomService } from '../../services/dom/dom.service';
import { ApplicationDropdownComponent } from '../../components/application-dropdown/application-dropdown.component';
import { GetPeopleQueryResponse, GET_PEOPLE } from '../graphql/queries';

/**
* Inits the people component.
*
* @param Survey survey library
* @param domService Dom service.
* @param apollo Apollo client.
*/
export const init = (
Survey: any,
domService: DomService,
apollo: Apollo
): void => {
// registers icon-people in the SurveyJS library
Survey.SvgRegistry.registerIconFromSvg(
'people',
'<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 0 24 24" width="18px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M9 13.75c-2.34 0-7 1.17-7 3.5V19h14v-1.75c0-2.33-4.66-3.5-7-3.5zM4.34 17c.84-.58 2.87-1.25 4.66-1.25s3.82.67 4.66 1.25H4.34zM9 12c1.93 0 3.5-1.57 3.5-3.5S10.93 5 9 5 5.5 6.57 5.5 8.5 7.07 12 9 12zm0-5c.83 0 1.5.67 1.5 1.5S9.83 10 9 10s-1.5-.67-1.5-1.5S8.17 7 9 7zm7.04 6.81c1.16.84 1.96 1.96 1.96 3.44V19h4v-1.75c0-2.02-3.5-3.17-5.96-3.44zM15 12c1.93 0 3.5-1.57 3.5-3.5S16.93 5 15 5c-.54 0-1.04.13-1.5.35.63.89 1 1.98 1 3.15s-.37 2.26-1 3.15c.46.22.96.35 1.5.35z"/></svg>'
);
const component = {
name: 'people',
title: 'People',
iconName: 'icon-people',
category: 'Custom Questions',
questionJSON: {
name: 'people',
type: 'tagbox',
optionsCaption: 'Select people...',
choicesOrder: 'asc',
choices: [] as any[],
},
onInit: (): void => {
Survey.Serializer.addProperty('people', {
name: 'applications',
category: 'people properties',
type: 'applicationsDropdown',
isDynamicChoices: true,
visibleIndex: 3,
required: true,
});

const applicationEditor = {
render: (editor: any, htmlElement: any) => {
const question = editor.object;
const dropdown = domService.appendComponentToBody(
ApplicationDropdownComponent,
htmlElement
);
const instance: ApplicationDropdownComponent = dropdown.instance;
instance.value = question.applications;
instance.choice.subscribe((res) => editor.onChanged(res));
},
};

SurveyCreator.SurveyPropertyEditorFactory.registerCustomEditor(
'applicationsDropdown',
applicationEditor
);
},
onLoaded: (question: any): void => {
apollo
.query<GetPeopleQueryResponse>({
query: GET_PEOPLE,
variables: {
applications: question.applications,
},
})
.subscribe(({ data }) => {
if (data.people) {
const people: any = [];
for (const person of data.people) {
if (!people.some((el: any) => el.value === person.id)) {
people.push({
value: person.id,
text: person.username,
email: person.email,
});
}
}
question.contentQuestion.choices = people;
}
});
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
onAfterRender: (): void => {},
};
Survey.ComponentCollection.Instance.add(component);
};
37 changes: 37 additions & 0 deletions libs/shared/src/lib/survey/graphql/queries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { gql } from 'apollo-angular';
import { Role, User } from '../../models/user.model';
import { Resource } from '../../models/resource.model';
import { Person } from '../../models/people.model';

// === GET ROLES FROM APPLICATION ===

Expand All @@ -12,6 +15,11 @@ export const GET_ROLES_FROM_APPLICATIONS = gql`
}
`;

/** Model for GetRolesFromApplicationsQueryResponse object */
export interface GetRolesFromApplicationsQueryResponse {
rolesFromApplications: Role[];
}

// === GET RESOURCE BY ID ===
/** Graphql request for getting data of a resource by its id */
export const GET_RESOURCE_BY_ID = gql`
Expand Down Expand Up @@ -60,6 +68,11 @@ export const GET_SHORT_RESOURCE_BY_ID = gql`
}
`;

/** Model for GetResourceByIdQueryResponse object */
export interface GetResourceByIdQueryResponse {
resource: Resource;
}

// === GET USERS ===

/** Graphql request for getting users (optionnally by a list of application ids) */
Expand All @@ -73,3 +86,27 @@ export const GET_USERS = gql`
}
}
`;

/** Model for GetUsersQueryResponse object */
export interface GetUsersQueryResponse {
users: User[];
}

// === GET PEOPLE ===

/** Graphql request for getting people */
export const GET_PEOPLE = gql`
query GetPeople($applications: [ID]) {
people(applications: $applications) {
id
username
name
oid
}
}
`;

/** Model for GetPeopleQueryResponse object */
export interface GetPeopleQueryResponse {
people: Person[];
}
2 changes: 2 additions & 0 deletions libs/shared/src/lib/survey/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as ResourceComponent from './components/resource';
import * as ResourcesComponent from './components/resources';
import * as OwnerComponent from './components/owner';
import * as UsersComponent from './components/users';
import * as PeopleComponent from './components/people';
import * as GeospatialComponent from './components/geospatial';
import * as TextWidget from './widgets/text-widget';
import * as CommentWidget from './widgets/comment-widget';
Expand Down Expand Up @@ -86,6 +87,7 @@ export const initCustomSurvey = (
);
OwnerComponent.init(Survey, domService, apollo);
UsersComponent.init(Survey, domService, apollo);
PeopleComponent.init(Survey, domService, apollo);
GeospatialComponent.init(Survey, domService);
}

Expand Down
5 changes: 3 additions & 2 deletions libs/shared/src/lib/survey/widgets/tagbox-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ export const init = (
afterRender: (question: QuestionTagbox, el: HTMLElement): void => {
const parentQuestion = question.parentQuestion;
if (
(parentQuestion && parentQuestion.getType() === 'matrixdynamic') ||
parentQuestion.getType() === 'matrixdropdown'
parentQuestion &&
(parentQuestion.getType() === 'matrixdynamic' ||
parentQuestion.getType() === 'matrixdropdown')
) {
question.choices = parentQuestion.choices;
}
Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/lib/utils/parser/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ const replaceRecordFields = (
break;
case 'owner':
case 'users':
case 'people':
case 'resources':
convertedValue = `<span style='${style}'>${
value ? value.length : 0
Expand Down