Skip to content

Commit

Permalink
JNG-5914 table tag representation
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Sep 5, 2024
1 parent 08ddb45 commit bf1d007
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { isErrorOperationFault, useErrorHandler } from '~/utilities';
import {} from '@mui/x-date-pickers';
import type {} from '@mui/x-date-pickers';
import {} from '~/components/widgets';
import { Tags } from '~/components/widgets';
import { useConfirmationBeforeChange } from '~/hooks';
import type { Planet, PlanetStored } from '~/services/data-api/model/Planet';
import { PLANET_VIEW_CONTAINER_ACTIONS_HOOK_INTERFACE_KEY } from './customization';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { isErrorOperationFault, useErrorHandler } from '~/utilities';
import { DateTimePicker } from '@mui/x-date-pickers';
import type { DateTimeValidationError } from '@mui/x-date-pickers';
import { NumericInput } from '~/components/widgets';
import { Tags } from '~/components/widgets';
import { autoFocusRefDelay } from '~/config';
import { useConfirmationBeforeChange } from '~/hooks';
import type { ViewAstronomer, ViewAstronomerStored } from '~/services/data-api/model/ViewAstronomer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { isErrorOperationFault, useErrorHandler } from '~/utilities';
import { DateTimePicker } from '@mui/x-date-pickers';
import type { DateTimeValidationError } from '@mui/x-date-pickers';
import { AssociationButton, NumericInput } from '~/components/widgets';
import { Tags } from '~/components/widgets';
import { useConfirmationBeforeChange } from '~/hooks';
import type { ViewAstronomer, ViewAstronomerStored } from '~/services/data-api/model/ViewAstronomer';
import type { ViewGalaxy, ViewGalaxyStored } from '~/services/data-api/model/ViewGalaxy';
Expand Down Expand Up @@ -158,19 +159,7 @@ export default function ViewGalaxyView(props: ViewGalaxyViewProps) {
alignItems="stretch"
justifyContent="flex-start"
>
<ViewGalaxyViewStarsComponent
uniqueId={
'God/(esm/_8AxbAE7tEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable'
}
actions={actions}
dataPath={dataPath ? dataPath + '.stars' : 'stars'}
ownerData={data}
editMode={editMode}
isFormUpdateable={isFormUpdateable}
validationError={validation.get('stars')}
refreshCounter={refreshCounter}
isOwnerLoading={isLoading}
/>
{'LMAO'}
</Grid>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5674,7 +5674,7 @@
<children xsi:type="ui:Flex" xmi:id="God/(esm/_CtcuYE7uEeycO-gUAWxcVg)/GroupVisualElement" name="group" sourceId="_CtcuYE7uEeycO-gUAWxcVg" fit="LOOSE" col="12.0" row="6.0" mainAxisAlignment="START">
<children xsi:type="ui:Flex" xmi:id="God/(esm/_D4bTwE7uEeycO-gUAWxcVg)/GroupVisualElement" name="group" sourceId="_D4bTwE7uEeycO-gUAWxcVg" label="Stars" fit="LOOSE" col="6.0" mainAxisAlignment="START">
<icon xmi:id="God/(esm/_D4bTwE7uEeycO-gUAWxcVg)/VisualElementIcon" name="group::Icon" iconName="star-shooting"/>
<children xsi:type="ui:Table" xmi:id="God/(esm/_8AxbAE7tEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable" name="stars" sourceId="_8AxbAE7tEeycO-gUAWxcVg" fit="LOOSE" col="12.0" row="6.0" disabled="true" isInCard="true" dataElement="God/(esm/_B7jpUE7sEeycO-gUAWxcVg)/RelationType" crudOperationsDisplayed="1" isEager="true" relationName="stars" selectorRowsPerPage="10">
<children xsi:type="ui:Table" xmi:id="God/(esm/_8AxbAE7tEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable" name="stars" sourceId="_8AxbAE7tEeycO-gUAWxcVg" fit="LOOSE" col="12.0" row="6.0" disabled="true" isInCard="true" dataElement="God/(esm/_B7jpUE7sEeycO-gUAWxcVg)/RelationType" crudOperationsDisplayed="1" isEager="true" relationName="stars" selectorRowsPerPage="10" representationComponent="TAG">
<columns xmi:id="God/(esm/_8AzQME7tEeycO-gUAWxcVg)/TableColumn/(discriminator/God/(esm/_8AxbAE7tEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable)" name="name" label="Name" col="2.0" format="%s" attributeType="God/(esm/_ePkuAE7rEeycO-gUAWxcVg)/AttributeType"/>
<filters xmi:id="God/(esm/_8AzQME7tEeycO-gUAWxcVg)/TableColumnFilter/(discriminator/God/(esm/_8AxbAE7tEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable)" name="name::Filter" label="Name" attributeType="God/(esm/_ePkuAE7rEeycO-gUAWxcVg)/AttributeType"/>
<tableActionButtonGroup xmi:id="God/(esm/_8AxbAE7tEeycO-gUAWxcVg)/TabularReferenceTableButtonGroup" name="View::Galaxy::View::group::group::stars::PageActions" label="Actions">
Expand Down Expand Up @@ -7299,7 +7299,7 @@
<children xsi:type="ui:TextInput" xmi:id="God/(esm/_GumaME7vEeycO-gUAWxcVg)/StringTypeTextInput" name="name" sourceId="_GumaME7vEeycO-gUAWxcVg" label="Name" fit="LOOSE" col="12.0" attributeType="God/(esm/_ePkuAE7rEeycO-gUAWxcVg)/AttributeType">
<icon xmi:id="God/(esm/_GumaME7vEeycO-gUAWxcVg)/VisualElementIcon" name="name::Icon" iconName="star"/>
</children>
<children xsi:type="ui:Table" xmi:id="God/(esm/_GuuWAE7vEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable" name="planets" sourceId="_GuuWAE7vEeycO-gUAWxcVg" label="Planets" fit="LOOSE" col="12.0" row="4.0" disabled="true" dataElement="God/(esm/_Hfxf0E7sEeycO-gUAWxcVg)/RelationType" crudOperationsDisplayed="1" isEager="true" relationName="planets" selectorRowsPerPage="10">
<children xsi:type="ui:Table" xmi:id="God/(esm/_GuuWAE7vEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable" name="planets" sourceId="_GuuWAE7vEeycO-gUAWxcVg" label="Planets" fit="LOOSE" col="12.0" row="4.0" disabled="true" dataElement="God/(esm/_Hfxf0E7sEeycO-gUAWxcVg)/RelationType" crudOperationsDisplayed="1" isEager="true" relationName="planets" selectorRowsPerPage="10" representationComponent="TAG">
<icon xmi:id="God/(esm/_GuuWAE7vEeycO-gUAWxcVg)/TabularReferenceFieldTableIcon" name="planets::Icon" iconName="earth"/>
<columns xmi:id="God/(esm/_GuyAYE7vEeycO-gUAWxcVg)/TableColumn/(discriminator/God/(esm/_GuuWAE7vEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable)" name="name" label="name" col="2.0" format="%s" attributeType="God/(esm/_oUXzwE7rEeycO-gUAWxcVg)/AttributeType"/>
<columns xmi:id="God/(esm/_KT3FUFjiEeyV2_3ibolaNQ)/TableColumn/(discriminator/God/(esm/_GuuWAE7vEeycO-gUAWxcVg)/TabularReferenceFieldRelationDefinedTable)" name="habitable" label="Habitable" col="2.0" format="%s" attributeType="God/(esm/_oUmdQE7rEeycO-gUAWxcVg)/AttributeType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public static List<Link> getLinksForPageContainers(Application application) {

public static List<Table> getTablesForPageContainers(Application application) {
return application.getPageContainers().stream().flatMap(c -> ((List<Table>) c.getTables()).stream())
.filter(t -> TableRepresentation.TABLE.equals(t.getRepresentationComponent()))
.collect(Collectors.toList());
}

public static List<Table> getTagsForPageContainers(Application application) {
return application.getPageContainers().stream().flatMap(c -> ((List<Table>) c.getTables()).stream())
.filter(t -> TableRepresentation.TAG.equals(t.getRepresentationComponent()))
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ public static String tableComponentName(Table table) {
.collect(Collectors.joining()) + "Component";
}

public static String tagComponentName(Table table) {
return tableComponentName(table);
}

public static boolean isTableTag(Table table) {
return TableRepresentation.TAG.equals(table.getRepresentationComponent());
}

public static Column getFirstAutocompleteColumnForLink(Link link) {
Optional<Column> column = link.getParts().stream()
.filter(c -> c.getAttributeType().getDataType() instanceof StringType && !c.getAttributeType().getIsMemberTypeTransient())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{{> fragment.header.hbs }}

import { useState, useEffect, useMemo, useRef, useCallback } from 'react';
import type { ElementType, MouseEvent, Dispatch, SetStateAction, FC } from 'react';
import { useTranslation } from 'react-i18next';
import type { JudoIdentifiable } from '~/services/data-api/common/JudoIdentifiable';
import type { JudoRestResponse } from '~/services/data-api/rest/requestResponse';
import Box from '@mui/material/Box';
import IconButton from '@mui/material/IconButton';
import Button from '@mui/material/Button';
import ButtonGroup from '@mui/material/ButtonGroup';
import Typography from '@mui/material/Typography';
import { GridLogicOperator, useGridApiRef } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}';
{{# if isMUILicensePlanPro }}
import { gridColumnDefinitionsSelector } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}';
{{/ if }}
import type {
GridColDef,
GridFilterModel,
GridRowModel,
GridRowId,
GridRenderCellParams,
GridRowSelectionModel,
GridSortItem,
GridSortModel,
GridRowClassNameParams,
GridRowParams,
GridValidRowModel,
} from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}';
import { baseColumnConfig, baseTableConfig, basePageSizeOptions{{# unless table.isEager }}, filterDebounceMs{{/ unless }} } from '~/config';
import { MdiIcon{{# unless table.isEager }}, CustomTablePagination{{/ unless }} } from '~/components';
import {
{{# if (tableHasBooleanColumn table) }}booleanColumnOperators,{{/ if }}
{{# if (tableHasDateColumn table) }}dateColumnOperators,{{/ if }}
{{# if (tableHasDateTimeColumn table) }}dateTimeColumnOperators,{{/ if }}
{{# if (tableHasNumericColumn table) }}numericColumnOperators,{{/ if }}
{{# if (tableHasEnumerationColumn table) }}singleSelectColumnOperators,{{/ if }}
{{# if isUseInlineColumnFilters }}stringColumnOperators,{{/ if }}
columnsActionCalculator,
ContextMenu,
StripedDataGrid,
EagerTable,
LazyTable,
} from '~/components/table';
import { Tags } from '~/components/widgets';
import { useConfirmDialog } from '~/components/dialog';
import type { ContextMenuApi } from '~/components/table/ContextMenu';
import type { Filter, FilterOption } from '~/components-api';
import { FilterType } from '~/components-api';
import { CUSTOM_VISUAL_ELEMENT_INTERFACE_KEY } from '~/custom';
{{# each (getTableAPIImports table container) as |imp| }}
import type {
{{ imp }},
{{ imp }}Stored,
} from '~/services/data-api/model/{{ imp }}';
import type {
{{ imp }}QueryCustomizer,
} from '~/services/data-api/rest/{{ imp }}QueryCustomizer';
{{/ each }}
{{# or (tableHasNumericColumn table) (tableHasDateColumn table) (tableHasDateTimeColumn table) }}
import { useL10N } from '~/l10n/l10n-context';
{{/ or }}
import {
TABLE_COLUMN_CUSTOMIZER_HOOK_INTERFACE_KEY,
randomUtils,
{{# if container.isSelector }}
isRowSelectable,
{{ else }}
getUpdatedRowsSelected,
{{/ if }}
{{# if table.isEager }}
applyInMemoryFilters,
{{/ if }}
{{# if (tableHasBinaryColumn table) }}
fileHandling,
{{/ if }}
{{# if isUseInlineColumnFilters }}
mapFilterModelToFilters,
mapFilterToFilterModel,
{{/ if }}
mapAllFiltersToQueryCustomizerProperties,
processQueryCustomizer,
serializeFilters,
deserializeFilters,
{{# unless table.isEager }}
useErrorHandler,
{{/ unless }}
} from '~/utilities';
import type { SidekickComponentProps, DialogResult, TableRowAction, ToolBarActionProps, ColumnCustomizerHook, FiltersSerializer{{# if isMUILicensePlanPro }}, PersistedColumnInfo{{/ if }} } from '~/utilities';
import { OBJECTCLASS } from '@pandino/pandino-api';
import { useTrackComponent, ComponentProxy } from '@pandino/react-hooks';
{{# if (stringValueIsTrue useTableRowHighlighting) }}
import { useTrackService } from '@pandino/react-hooks';
import { RowHighlightLegend } from '~/components/table';
import { TABLE_ROW_HIGHLIGHTING_HOOK_INTERFACE_KEY, transformRowStylings } from '~/theme/table-row-highlighting';
import type { RowStylerConfigured, TableRowHighlightingHook } from '~/theme/table-row-highlighting';
{{/ if }}
import type { {{ componentName table }}ActionDefinitions, {{ componentName table }}Props } from './types';
import { {{ classDataName (getReferenceClassType table) 'StoredSerializer' }} } from '~/services/data-api/rest/{{ classDataName (getReferenceClassType table) 'Serializer' }}';


export const filtersSerializer: FiltersSerializer = {
serialize: (filters: Filter[]) => serializeFilters<{{ classDataName (getReferenceClassType table) 'Stored' }}>(filters, {{ classDataName (getReferenceClassType table) 'StoredSerializer' }}.getInstance()),
deserialize: (filters: Filter[]) => deserializeFilters<{{ classDataName (getReferenceClassType table) 'Stored' }}>(filters, {{ classDataName (getReferenceClassType table) 'StoredSerializer' }}.getInstance()),
};

// XMIID: {{ getXMIID table }}
// Name: {{ table.name }}
export function {{ componentName table }}(props: {{ componentName table }}Props) {
const {
uniqueId,
actions,
dataPath,
isOwnerLoading,
isDraft,
validationError,
ownerData,
editMode,
isFormUpdateable,
} = props;

return (
<div id="{{ getXMIID table }}" data-table-name="{{ table.name }}">
<Tags<{{ classDataName container.dataElement '' }}, {{ classDataName (getReferenceClassType table) 'Stored' }}>
id="{{ getXMIID table }}"
label={'KUKAC'}
helperText={validationError}
error={!!validationError}
editMode={editMode}
ownerData={ownerData}
name="{{ table.relationName }}"
disabled={!isFormUpdateable()}
autoCompleteAttribute="{{ table.columns.[0].attributeType.name }}"
onAutoCompleteSearch={ async (searchText, preparedQueryCustomizer) => {
alert('lol');
return Promise.resolve([]);
} }
onValueChange={ async (values) => {
console.log(values);
} }
onItemClick={(target) => alert('A')}
onSearchDialogsClick={() => alert('B')}
onClearDialogsClick={() => alert('C')}
identifierAttribute="__identifier"
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import type { ElementType, Dispatch, SetStateAction } from 'react';
import type {
GridFilterModel,
} from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}';
{{# each (getTableAPIImports table container) as |imp| }}
import type {
{{ imp }},
{{ imp }}Stored,
} from '~/services/data-api/model/{{ imp }}';
import type {
{{ imp }}QueryCustomizer,
} from '~/services/data-api/rest/{{ imp }}QueryCustomizer';
{{/ each }}
import type { JudoRestResponse } from '~/services/data-api/rest/requestResponse';
import type { Filter, FilterOption } from '~/components-api';
import type { DialogResult } from '~/utilities';

export interface {{ componentName table }}ActionDefinitions {
get{{ firstToUpper table.relationName }}Mask?: () => string;
get{{ firstToUpper table.relationName }}RowRepresentation?: (row: {{ classDataName (getReferenceClassType table) 'Stored' }}) => string;
{{# each table.tableActionDefinitions as |actionDefinition| }}
{{# if actionDefinition.isFilterAction }}
{{ simpleActionDefinitionName actionDefinition }}?: (id: string, filterOptions: FilterOption[], model?: GridFilterModel, filters?: Filter[]) => Promise<{ model?: GridFilterModel; filters?: Filter[] }>;
{{ else }}
{{# if actionDefinition.isRefreshAction }}
{{ simpleActionDefinitionName actionDefinition }}?: (queryCustomizer: {{ classDataName (getReferenceClassType table) 'QueryCustomizer' }}) => Promise<JudoRestResponse<{{ classDataName (getReferenceClassType table) 'Stored' }}[]>>;
{{ else }}
{{# if actionDefinition.isExportAction }}
{{ simpleActionDefinitionName actionDefinition }}?: (queryCustomizer: {{ classDataName (getReferenceClassType table) 'QueryCustomizer' }}) => Promise<void>;
{{ else }}
{{# if actionDefinition.isSelectorRangeAction }}
{{ simpleActionDefinitionName actionDefinition }}?: (queryCustomizer: {{ classDataName (getReferenceClassType table) 'QueryCustomizer' }}) => Promise<JudoRestResponse<{{ classDataName (getReferenceClassType table) 'Stored' }}[]>>;
{{ else }}
{{# if actionDefinition.isBulk }}
{{ simpleActionDefinitionName actionDefinition }}?: (selectedRows: {{ classDataName (getReferenceClassType table) 'Stored' }}[]) => Promise<DialogResult<{{ classDataName (getReferenceClassType table) 'Stored' }}[]>>;
{{ else }}
{{ simpleActionDefinitionName actionDefinition }}?: ({{# if actionDefinition.targetType }}target: {{ classDataName actionDefinition.targetType 'Stored' }}{{/ if }}) => Promise<void>;
{{/ if }}
{{/ if }}
{{/ if }}
{{/ if }}
{{/ if }}
{{/ each }}
{{# each table.rowActionDefinitions as |actionDefinition| }}
{{ simpleActionDefinitionName actionDefinition }}?: (row: {{ classDataName (getReferenceClassType table) 'Stored' }}{{# if actionDefinition.isOpenPageAction }}, isDraft?: boolean{{/ if }}) => Promise<void>;
{{/ each }}
{{ table.relationType.name }}AdditionalToolbarButtons?: (
{{# with (getReferenceClassType table) as |classType| }}
data: {{# if classType.isMapped }}{{ classDataName classType 'Stored' }}{{ else }}{{ classDataName classType '' }}{{/ if }}[],
{{/ with }}
isLoading: boolean,
selectedRows: {{ classDataName (getReferenceClassType table) 'Stored' }}[],
clearSelections: () => void
{{# unless container.table }}
, ownerData: {{ classDataName container.dataElement 'Stored' }}
, editMode: boolean
, isFormUpdateable: () => boolean
{{/ unless }}
) => Record<string, ElementType>;
}

export interface {{ componentName table }}Props {
uniqueId: string;
actions: {{ componentName table }}ActionDefinitions;
dataPath?: string;
isOwnerLoading?: boolean;
isDraft?: boolean;
validationError?: string;
ownerData: {{ classDataName container.dataElement 'Stored' }};
editMode: boolean;
isFormUpdateable: () => boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useTrackService } from '@pandino/react-hooks';
{{> actor/src/fragments/container/view-imports.fragment.hbs }}
{{/ unless }}
{{# unless (containerIsEmptyDashboard container) }}
import { Tags } from '~/components/widgets';
{{# each (getContainerApiImports container) as |imp| }}
import type { {{ classDataName imp '' }}, {{ classDataName imp 'Stored' }} } from '~/services/data-api/model/{{ classDataName imp '' }}';
{{/ each }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
{{/ if }}
<Grid item xs={12} sm={12}>
<Grid id="{{ getXMIID child }}" container direction="column" alignItems="stretch" justifyContent="flex-start">
{{# unless (isTableTag child) }}
<{{ componentName child }}
uniqueId={'{{ getXMIID child }}'}
actions={actions}
Expand All @@ -52,6 +53,9 @@
refreshCounter={refreshCounter}
isOwnerLoading={isLoading}
/>
{{ else }}
{'LMAO'}
{{/ unless }}
</Grid>
</Grid>
</Grid>
Expand Down
Loading

0 comments on commit bf1d007

Please sign in to comment.