Skip to content

Commit

Permalink
added new story task mode: edit
Browse files Browse the repository at this point in the history
  • Loading branch information
framefactory committed Oct 13, 2019
1 parent 52dabc6 commit 1fb188a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
18 changes: 14 additions & 4 deletions source/client/applications/StoryApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ import NVTasks from "../nodes/NVTasks";
import NVoyagerStory from "../nodes/NVoyagerStory";

import MainView from "../ui/story/MainView";
import CVTaskProvider from "../components/CVTaskProvider";
import { ETaskMode } from "./taskSets";
import CVTaskProvider, { ETaskMode } from "../components/CVTaskProvider";

////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -157,8 +156,19 @@ export default class StoryApplication
const app = this.system.getMainComponent(CVStoryApplication);
app.referrer = props.referrer;

const lcMode = props.mode[0].toLowerCase();
const mode = lcMode === "a" ? ETaskMode.Authoring : (lcMode === "e" ? ETaskMode.Expert : ETaskMode.QC);
const modeText = props.mode.toLowerCase();
let mode = ETaskMode.Edit;

if (modeText.startsWith("au")) {
mode = ETaskMode.Authoring;
}
else if (modeText.startsWith("qc")) {
mode = ETaskMode.QC;
}
else if (modeText.startsWith("ex")) {
mode = ETaskMode.Expert;
}

const tasks = this.system.getMainComponent(CVTaskProvider);
tasks.ins.mode.setValue(mode);
}
Expand Down
11 changes: 10 additions & 1 deletion source/client/applications/taskSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ import CVToursTask from "../components/CVToursTask";

////////////////////////////////////////////////////////////////////////////////

export enum ETaskMode { QC, Authoring, Expert }
export enum ETaskMode { QC, Authoring, Edit, Expert }

export default {
[ETaskMode.Edit]: [
CVPoseTask,
CVCaptureTask,
CVDerivativesTask,
CVAnnotationsTask,
CVArticlesTask,
CVToursTask,
CVSettingsTask,
],
[ETaskMode.QC]: [
CVPoseTask,
CVCaptureTask,
Expand Down
36 changes: 22 additions & 14 deletions source/client/components/CVStoryApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,44 @@ export default class CVStoryApplication extends Component
{
const ins = this.ins;


if (ins.exit.changed && this.referrer) {
location.assign(this.referrer);
}

const document = this.documentProvider.activeComponent;
const mode = this.taskProvider.ins.mode.getValidatedValue();
const components: INodeComponents = mode === ETaskMode.QC ? { model: true } : null;

if (document && ins.save.changed) {
const data = document.deflateDocument(components);
const json = JSON.stringify(data, (key, value) =>
typeof value === "number" ? parseFloat(value.toFixed(7)) : value);
if (document) {
// in QC mode, only save the model, but no scene data, in all other modes, save everything
const storyMode = this.taskProvider.ins.mode.getValidatedValue();
const components: INodeComponents = storyMode === ETaskMode.QC ? { model: true } : null;

if (ins.save.changed) {
const data = document.deflateDocument(components);
const json = JSON.stringify(data, (key, value) =>
typeof value === "number" ? parseFloat(value.toFixed(7)) : value);

this.assetWriter.putJSON(json, document.assetPath)
this.assetWriter.putJSON(json, document.assetPath)
.then(() => new Notification(`Successfully uploaded file to '${document.assetPath}'`, "info", 4000))
.catch(e => new Notification(`Failed to upload file to '${document.assetPath}'`, "error", 8000));
}
}

if (document && ins.download.changed) {
const data = document.deflateDocument(components);
const json = JSON.stringify(data, null, 2);
if (ins.download.changed) {
const data = document.deflateDocument(components);
const json = JSON.stringify(data, null, 2);

const fileName = this.assetManager.getAssetName(document.assetPath);
download.json(json, fileName);
const fileName = this.assetManager.getAssetName(document.assetPath);
download.json(json, fileName);
}
}


return false;
}

/**
* Provoke a user prompt before unloading the page
* @param event
*/
protected beforeUnload(event)
{
event.returnValue = "x";
Expand Down

0 comments on commit 1fb188a

Please sign in to comment.