Skip to content

Commit

Permalink
rename variable and use new alert type in other place
Browse files Browse the repository at this point in the history
  • Loading branch information
jrchudy committed Sep 20, 2024
1 parent 1bacdc5 commit 1a531e3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/components/recordedit/form-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,18 @@ const FormRow = ({
const safeClassNameId = `${formNumber}-${makeSafeIdAttr(column.displayname.value)}`;

const tempForeignKeyCallbacks = { ...foreignKeyCallbacks };
const prefill = reference.bulkCreateForeignKeyObject;
const bulkFKObject = reference.bulkCreateForeignKeyObject;
/**
* add foreignkey callbacks to generated input if:
* - there is a bulkCreateForeignKeyObject defined
* - there is a pair of columns that create a unique assocation that use the prefill behavior
* - the column is a foreignkey
* - and the column is the one used for associating to the leaf table of the association
*/
if (prefill?.isUnique && column.isForeignKey && prefill.leafColumn.name === colName) {
if (bulkFKObject?.isUnique && column.isForeignKey && bulkFKObject.leafColumn.name === colName) {
tempForeignKeyCallbacks.getDisabledTuples = disabledTuplesPromise(
column.reference.contextualize.compactSelectForeignKey,
prefill.disabledRowsFilter(),
bulkFKObject.disabledRowsFilter(),
bulkForeignKeySelectedRows
);

Expand Down
5 changes: 2 additions & 3 deletions src/components/recordedit/recordedit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const RecordeditInner = ({

const { validateSessionBeforeMutation } = useAuthn();
const { errors, dispatchError } = useError();
const { addAlert } = useAlert();
const { addTooManyFormsAlert } = useAlert();
const {
appMode, columnModels, config, foreignKeyData, initialized, modalOptions,
prefillObject, bulkForeignKeySelectedRows, setbulkForeignKeySelectedRows,
Expand Down Expand Up @@ -323,7 +323,6 @@ const RecordeditInner = ({
const domainRef: any = bulkFKObject.leafColumn.reference;
const andFilters: any[] = bulkFKObject.andFiltersForLeaf();

// TODO: think about this more if it's required in this context
// if filter in source is based on the related table, then we would need to add it as a hidden custom filter here.
let customFacets: any = null;
if (
Expand Down Expand Up @@ -452,7 +451,7 @@ const RecordeditInner = ({
const numberFormsAllowed = MAX_ROWS_TO_ADD - numberForms
let alertMessage = `Cannot add ${numberFormsToAdd} records. Please input a value between 1 and ${numberFormsAllowed}, inclusive.`;
if (numberFormsAllowed === 0) alertMessage = `Cannot add ${numberFormsToAdd} records. Maximum number of forms already added.`;
addAlert(alertMessage, ChaiseAlertType.ERROR);
addTooManyFormsAlert(alertMessage, ChaiseAlertType.ERROR);
setShowCloneSpinner(false);
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/providers/alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const AlertsContext = createContext<{
removeAlert: RemoveAlertFunction,
addURLLimitAlert: () => void,
removeURLLimitAlert: () => void,
addTooManyFormsAlert:(message: string) => void,
addTooManyFormsAlert:(message: string, type: ChaiseAlertType) => void,
removeTooManyFormsAlert:() => void,
removeAllAlerts: () => void,
} |
Expand Down Expand Up @@ -126,10 +126,10 @@ export default function AlertsProvider({ children }: AlertsProviderProps): JSX.E
urlLimitAlert.current = null;
}

const addTooManyFormsAlert = (message: string) => {
const addTooManyFormsAlert = (message: string, type: ChaiseAlertType) => {
if (tooManyFormsAlert.current) return;

tooManyFormsAlert.current = addAlert(message, ChaiseAlertType.WARNING, () => tooManyFormsAlert.current = null)
tooManyFormsAlert.current = addAlert(message, type, () => tooManyFormsAlert.current = null)
}

const removeTooManyFormsAlert = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/recordset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export default function RecordsetProvider({
if (numberFormsAllowed === 0) alertMessage = `Cannot select ${res.length} records. Maximum number of forms already added.`;

if (temp === false) {
addTooManyFormsAlert(alertMessage)
addTooManyFormsAlert(alertMessage, ChaiseAlertType.WARNING);
} else {
removeTooManyFormsAlert();
}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/specs/delete-prohibited/recordset/facet.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export default getConfig({
configFileName: 'recordset/facet.dev.json',
mainSpecName: 'delete-prohibited',
testMatch: [
// 'facet-presentation.spec.ts',
// 'individual-facet.spec.ts',
// 'four-facet-selections.spec.ts',
'facet-presentation.spec.ts',
'individual-facet.spec.ts',
'four-facet-selections.spec.ts',
'misc-facet.spec.ts',
// 'reorder-facet.spec.ts'
'reorder-facet.spec.ts'
]
});

0 comments on commit 1a531e3

Please sign in to comment.