Skip to content

Commit

Permalink
Select different PerspectiveView for different perspective types.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Oct 31, 2023
1 parent 00a5499 commit dab0a05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
27 changes: 12 additions & 15 deletions src/components/LexicalEntryCorp/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,18 @@ const TextEntityContent = ({
}
}

const pg_ln = /\[\d+[ab]:\d+\]/;
const pg = /\[\d+[ab]?\]/;
const ln = /\(\d+\)/;
const snt = /\/{2}/;
const missed = /[/]missed text[/]/;
// TODO: change 'number' to something meaningful
const metatext = number
? new RegExp(
pg_ln.source + "|" +
pg.source + "|" +
ln.source + "|" +
snt.source + "|" +
missed.source
)
: new RegExp();
const pg_ln = /\[\d+[ab]?:\d+\]/;
const pg = /\[\d+[ab]?\]/;
const ln = /\(\d+\)/;
const snt = /\/{2}/;
const missed = /[/]missed text[/]/;
const metatext = new RegExp(
pg_ln.source + "|" +
pg.source + "|" +
ln.source + "|" +
snt.source + "|" +
missed.source
);

switch (mode) {
case "edit":
Expand Down
18 changes: 12 additions & 6 deletions src/pages/Perspective/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { branch, compose, onlyUpdateForKeys, renderNothing, withHandlers, withSt
import { chooseTranslation as T } from "api/i18n";
import { queryCounter } from "backend";
import Merge from "components/Merge";
/*import PerspectiveView from "components/PerspectiveView";*/
import PerspectiveView from "components/CorporaView";
import PerspectiveView from "components/PerspectiveView";
import CorporaView from "components/CorporaView";
import { useMutation } from "hooks";
import TranslationContext from "Layout/TranslationContext";
import NotFound from "pages/NotFound";
Expand All @@ -44,6 +44,10 @@ export const perspectiveIsHiddenOrDeletedQuery = gql`
id
is_hidden_for_client
marked_for_deletion
additional_metadata
{
parallel
}
tree {
id
marked_for_deletion
Expand Down Expand Up @@ -1260,32 +1264,34 @@ const Perspective = ({
);
}
const isDeleted = p.marked_for_deletion || p.tree.some(entity => entity.marked_for_deletion);
const parallelCorpora = p.additional_metadata.parallel;
const Viewer = parallelCorpora ? CorporaView : PerspectiveView;

const modes = {};
if (user.id !== undefined) {
Object.assign(modes, {
edit: {
entitiesMode: "all",
text: getTranslation("Edit"),
component: PerspectiveView
component: Viewer
},
publish: {
entitiesMode: "all",
text: getTranslation("Publish"),
component: PerspectiveView
component: Viewer
}
});
}
Object.assign(modes, {
view: {
entitiesMode: "published",
text: getTranslation("View published"),
component: PerspectiveView
component: Viewer
},
contributions: {
entitiesMode: "not_accepted",
text: getTranslation("View contributions"),
component: PerspectiveView
component: Viewer
},
merge: {
entitiesMode: "all",
Expand Down

0 comments on commit dab0a05

Please sign in to comment.