Skip to content

Commit 1f90171

Browse files
feat: allow to define grid actions in summary card settings (#1888)
* Allow-to-define-grid-actions-from-summary-card-settings * lint * duplication of grid actions in summary cards --------- Co-authored-by: Antoine Hurard <[email protected]>
1 parent f697ea0 commit 1f90171

File tree

13 files changed

+146
-26
lines changed

13 files changed

+146
-26
lines changed
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnInit, Inject } from '@angular/core';
1+
import { Component, Input, OnInit } from '@angular/core';
22
import { UntypedFormGroup } from '@angular/forms';
33
import { ApplicationService } from '../../../../services/application/application.service';
44
import { Application } from '../../../../models/application.model';
@@ -24,8 +24,6 @@ export class TabActionsComponent
2424
public showSelectPage = false;
2525
/** Available pages from the application */
2626
public pages: any[] = [];
27-
/** Current environment */
28-
private environment: any;
2927
/** Grid actions */
3028
public actions = [
3129
{
@@ -78,15 +76,10 @@ export class TabActionsComponent
7876
/**
7977
* Constructor of the grid component
8078
*
81-
* @param applicationService Application service,
82-
* @param environment environment
79+
* @param applicationService Application service
8380
*/
84-
constructor(
85-
public applicationService: ApplicationService,
86-
@Inject('environment') environment: any
87-
) {
81+
constructor(public applicationService: ApplicationService) {
8882
super();
89-
this.environment = environment;
9083
}
9184

9285
ngOnInit(): void {

libs/shared/src/lib/components/widgets/grid-settings/grid-settings.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
33
import { GridSettingsComponent } from './grid-settings.component';
44
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
55
import { TranslateModule } from '@ngx-translate/core';
6-
import { TabActionsModule } from './tab-actions/tab-actions.module';
6+
import { TabActionsModule } from '../common/tab-actions/tab-actions.module';
77
import { TabButtonsModule } from './tab-buttons/tab-buttons.module';
88
import { TabMainModule } from './tab-main/tab-main.module';
99
import {

libs/shared/src/lib/components/widgets/summary-card-settings/graphql/queries.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,69 @@ export const GET_RESOURCE = gql`
124124
}
125125
}
126126
`;
127+
128+
// === GET RELATED FORMS FROM RESOURCE ===
129+
130+
/** Graphql request for getting resource meta date for a grid */
131+
export const GET_GRID_RESOURCE_META = gql`
132+
query GetGridResourceMeta(
133+
$resource: ID!
134+
$layoutIds: [ID]
135+
$firstLayouts: Int
136+
$aggregationIds: [ID]
137+
$firstAggregations: Int
138+
) {
139+
resource(id: $resource) {
140+
id
141+
name
142+
queryName
143+
forms {
144+
id
145+
name
146+
}
147+
relatedForms {
148+
id
149+
name
150+
fields
151+
resource {
152+
id
153+
queryName
154+
name
155+
fields
156+
}
157+
}
158+
layouts(ids: $layoutIds, first: $firstLayouts) {
159+
edges {
160+
node {
161+
id
162+
name
163+
query
164+
createdAt
165+
display
166+
}
167+
}
168+
pageInfo {
169+
hasNextPage
170+
endCursor
171+
}
172+
totalCount
173+
}
174+
aggregations(ids: $aggregationIds, first: $firstAggregations) {
175+
edges {
176+
node {
177+
id
178+
name
179+
sourceFields
180+
pipeline
181+
createdAt
182+
}
183+
}
184+
pageInfo {
185+
hasNextPage
186+
endCursor
187+
}
188+
totalCount
189+
}
190+
}
191+
}
192+
`;

libs/shared/src/lib/components/widgets/summary-card-settings/summary-card-general/summary-card-general.component.html

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,42 @@
55
</div>
66

77
<ng-container formGroupName="card">
8-
<!-- RESOURCE SELECTION -->
9-
<div uiFormFieldDirective>
10-
<label>{{ 'models.resource.select' | translate }}</label>
11-
<ui-graphql-select
12-
valueField="id"
13-
textField="name"
14-
[query]="resourcesQuery"
15-
formControlName="resource"
16-
[selectedElements]="[selectedResource]"
17-
(searchChange)="onResourceSearchChange($event)"
18-
[filterable]="true"
19-
></ui-graphql-select>
8+
<div class="flex gap-2 flex-wrap">
9+
<!-- RESOURCE SELECTION -->
10+
<div uiFormFieldDirective class="flex-1">
11+
<label>{{ 'models.resource.select' | translate }}</label>
12+
<ui-graphql-select
13+
valueField="id"
14+
textField="name"
15+
[query]="resourcesQuery"
16+
formControlName="resource"
17+
[selectedElements]="[selectedResource]"
18+
(searchChange)="onResourceSearchChange($event)"
19+
[filterable]="true"
20+
></ui-graphql-select>
21+
</div>
22+
23+
<!-- TEMPLATE SELECTION -->
24+
<div uiFormFieldDirective class="flex-1">
25+
<label>{{ 'models.form.template' | translate }}</label>
26+
<ui-select-menu formControlName="template">
27+
<ui-select-option>-</ui-select-option>
28+
<ui-select-option
29+
*ngFor="let template of templates"
30+
[value]="template.id"
31+
>
32+
{{ template.name }}
33+
</ui-select-option>
34+
</ui-select-menu>
35+
<ui-icon
36+
uiSuffix
37+
icon="info_outline"
38+
variant="grey"
39+
[uiTooltip]="
40+
'components.widget.settings.grid.tooltip.template' | translate
41+
"
42+
></ui-icon>
43+
</div>
2044
</div>
2145

2246
<!-- SELECT AGGREGATION OR LAYOUT -->

libs/shared/src/lib/components/widgets/summary-card-settings/summary-card-general/summary-card-general.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
} from '@oort-front/ui';
3939
import { Dialog } from '@angular/cdk/dialog';
4040
import { GET_RESOURCES } from '../graphql/queries';
41+
import { Form } from '../../../../models/form.model';
4142

4243
/** Default number of resources to be fetched per page */
4344
const ITEMS_PER_PAGE = 10;
@@ -78,6 +79,7 @@ export class SummaryCardGeneralComponent
7879
@Input() selectedResource: Resource | null = null;
7980
@Input() selectedLayout: Layout | null = null;
8081
@Input() selectedAggregation: Aggregation | null = null;
82+
@Input() templates: Form[] = [];
8183

8284
@Output() resourceChange = new EventEmitter<Resource | null>();
8385
@Output() layoutChange = new EventEmitter<Layout | null>();

libs/shared/src/lib/components/widgets/summary-card-settings/summary-card-settings.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<shared-summary-card-general
1919
[tileForm]="tileForm"
2020
[selectedResource]="selectedResource"
21+
[templates]="templates"
2122
[selectedLayout]="selectedLayout"
2223
[selectedAggregation]="selectedAggregation"
2324
(resourceChange)="handleResourceChange($event)"

0 commit comments

Comments
 (0)