Skip to content

Commit

Permalink
properties.shouldShow()
Browse files Browse the repository at this point in the history
  • Loading branch information
hatton committed Mar 30, 2024
1 parent 84bf704 commit 0e14af4
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 26 deletions.
18 changes: 2 additions & 16 deletions archive-configurations/ELAR/fields.json5
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@
description: "This is usually the same person as the Collection Steward."
}
],
session: [
{
key: "description"
//multilingual: true
},
{
key: "customFields",
visibility: "never"
}
],
people: [
{
key: "customFields",
visibility: "never"
}
]
session: [],
people: []
}
2 changes: 1 addition & 1 deletion archive-configurations/lameta/fields.json5
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{
key: "archiveConfigurationName",
form: "ArchiveConfiguration",
default: "unknown",
default: "default",
xmlTag: "ArchiveConfigurationName",
englishLabel: "Archive Configuration used by this project",
vocabulary: "ArchiveConfigurationName"
Expand Down
2 changes: 2 additions & 0 deletions e2e/e2eFileList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class E2eFileList {
// this gets really flaky with the mocking and background copying.
// for now, if we actualy need this file, let's just put it where we want it
if (wait) {
// pause for a second
await this.page.waitForTimeout(500);
fs.writeFileSync(wait.path, "hello world");

await waitForCondition(wait.page, () => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"//----watch": "The nature of watch is that we can't run two commands, so you'll have to have 2 terminals if you want to watch both",
"//---build-is-what-github-actions-runs": "",
"build": "yarn strings:extract && tsc && yarn vite build",
"e2ebuild": "yarn vite build --config vite.config.nonminified.js",
"postinstall": "yarn patch-package && electron-builder install-app-deps",
"//----dev": "this is the normal day-to-day way of running while developing, with compiling of main, preload, and render",
"dev": "yarn check-node && vite",
Expand Down
2 changes: 2 additions & 0 deletions src/ArchiveConfigurationSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const ArchiveConfigurationSummary: React.FunctionComponent<
const personCustomizations = customizations.filter(
(c) => c.area === "person"
);
console.log("****", props.configurationName);

return (
<div>
<h2>Session Access Choices</h2>
Expand Down
5 changes: 3 additions & 2 deletions src/components/AutoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ class AutoForm extends React.Component<IProps> {
f.definition.visibility !== "never" &&
f.definition.showOnAutoForm &&
!f.definition.isCustom &&
!f.definition.isAdditional
!f.definition.isAdditional &&
f.definition.key !== "customFields" // this is handled special, below
)
.sort((a, b) => {
const x =
Expand Down Expand Up @@ -199,7 +200,7 @@ class AutoForm extends React.Component<IProps> {
) : (
""
)}
{this.props.folder.hasCustomFieldsTable ? (
{this.props.folder.properties.shouldShow("customFields") ? (
<CustomFieldsTable file={this.props.folder.metadataFile!} />
) : (
""
Expand Down
3 changes: 0 additions & 3 deletions src/model/Folder/Folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ export abstract class Folder {
public get hasMoreFieldsTable(): boolean {
return false;
}
public get hasCustomFieldsTable(): boolean {
return false;
}

public abstract importIdMatchesThisFolder(id: string): boolean;
public abstract get folderType(): IFolderType;
Expand Down
4 changes: 0 additions & 4 deletions src/model/Project/Session/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ export class Session extends Folder {
public get hasMoreFieldsTable(): boolean {
return true;
}
public get hasCustomFieldsTable(): boolean {
return true;
}

// A note about name vs. ID. Here "ID" may be the name or the code, since
// the rule we inherited from SM Classic is that if a Person has something
// in the "code" field, then that acts as the display name and id around
Expand Down
14 changes: 14 additions & 0 deletions src/model/field/FieldSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,18 @@ export class FieldSet extends Dictionary<string, Field> {
field.key = newKey;
this.setValue(field.key, field);
}

public shouldShow(key: string): boolean {
if (!this.containsKey(key)) {
return false;
}
if (this.getValueOrThrow(key).definition.visibility === "never") {
return false;
}
// support "ifNotEmpty"
if (this.getValueOrThrow(key).definition.visibility === "ifNotEmpty") {
return this.getHasValue(key);
}
return true;
}
}
11 changes: 11 additions & 0 deletions vite.config.nonminified.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "vite";
import baseConfig from "./vite.config";

export default defineConfig({
...baseConfig,
build: {
...baseConfig.build,
minify: false,
cssMinify: false
}
});

0 comments on commit 0e14af4

Please sign in to comment.