Skip to content

Commit

Permalink
refactor: renaming checkbox->selectionMark (#223)
Browse files Browse the repository at this point in the history
* initial commit - renaming checkbox->selectionMark

* refactor: rename checkbox to selectionMark

Co-authored-by: kunzheng <58841788+kunzms@users.noreply.github.com>
Co-authored-by: kunzms <kunzheng@microsoft.com>
  • Loading branch information
3 people authored May 1, 2020
1 parent 5bacea4 commit f6c8ffa
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 73 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# react-scripts build use this to generate the right path for assets
# relative to index.html
# without it, you'll see error like this
# Failed to load resource: net::ERR_FILE_NOT_FOUND /favicon.ico:1
PUBLIC_URL=.
105 changes: 51 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"jquery": "^3.5.0",
"kind-of": "^6.0.3",
"minimist": "^1.2.2",
"node-sass": "^4.13.0",
"node-sass": "^4.14.0",
"pdfjs-dist": "2.3.200",
"react-scripts": "3.1.2",
"redux-immutable-state-invariant": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Guard from "./guard";
import { IProject, ISecurityToken, IProviderOptions, ISecureString, ITag } from "../models/applicationState";
import { encryptObject, decryptObject, encrypt, decrypt } from "./crypto";
import UTIF from "utif";
import HtmlFileReader from "./htmlFileReader";

// tslint:disable-next-line:no-var-requires
const tagColors = require("../react/components/common/tagColors.json");

Expand Down
2 changes: 1 addition & 1 deletion src/models/applicationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export enum FieldType {
Date = "date",
Time = "time",
Integer = "integer",
Checkbox = "checkbox",
SelectionMark = "selectionMark",
}

export enum FieldFormat {
Expand Down
1 change: 0 additions & 1 deletion src/react/components/common/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default class Alert extends React.Component<IAlertProps, IAlertState> {
},
scopedSettings: {},
};
const confirmButtonTheme = this.props.confirmButtonTheme;

return (
<Customizer {...dark}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function ArrayFieldTemplate(props: ArrayFieldTemplateProps) {
document.getElementById("addSecurityToken").focus();
setFocusFlag(false);
}
});
}, [focusFlag]);

return (
<div>
Expand Down
2 changes: 0 additions & 2 deletions src/react/components/common/assetPreview/pdfAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import React from "react";
import { IAssetPreviewProps } from "./assetPreview";
import * as pdfjsLib from "pdfjs-dist";
import { constants } from "../../../../common/constants";
import utils from "../imageMap/utils";
import {resizeCanvas} from "../../../../common/utils";
import {IAsset} from "../../../../models/applicationState";

// temp hack for enabling worker
pdfjsLib.GlobalWorkerOptions.workerSrc = constants.pdfjsWorkerSrc(pdfjsLib.version);
Expand Down
6 changes: 3 additions & 3 deletions src/react/components/pages/editorPage/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
}

if (selectedRegions.length === 1 && selectedRegions[0].category === FeatureCategory.Checkbox) {
this.setTagType(inputTag[0], FieldType.Checkbox);
this.setTagType(inputTag[0], FieldType.SelectionMark);
}

this.redrawAllFeatures();
Expand Down Expand Up @@ -1547,7 +1547,7 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
const newRegion = {
id: this.createRegionIdFromBoundingBox(boundingBox, pangeNumber),
type: RegionType.Polygon,
category: tag.type === FieldType.Checkbox ? FeatureCategory.Checkbox : FeatureCategory.Text,
category: tag.type === FieldType.SelectionMark ? FeatureCategory.Checkbox : FeatureCategory.Text,
tags: [tagName],
boundingBox: {
height: bottom - top,
Expand Down Expand Up @@ -1669,7 +1669,7 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
const prevType = prevTypes[name];
const type = types[name];
if (prevType !== type
&& (prevType === FieldType.Checkbox || type === FieldType.Checkbox)) {
&& (prevType === FieldType.SelectionMark || type === FieldType.SelectionMark)) {
// some tag change between checkbox and text
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/react/components/pages/editorPage/canvasCommandBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const CanvasCommandBar: React.FunctionComponent<ICanvasCommandBarProps> =
onClick: () => props.handleLayerChange("tables"),
},
{
key: "checkboxes",
text: "Checkboxes (Preview)",
key: "selectionMark",
text: "Selection Marks (Preview)",
canCheck: true,
iconProps: { iconName: "CheckboxComposite" },
isChecked: props.layers["checkboxes"],
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/pages/predict/predictPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
this.imageMap.removeAllFeatures();
}
});
}) .catch((error) => {
}).catch((error) => {
this.setState({
isFetching: false,
shouldShowAlert: true,
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/pages/train/trainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export default class TrainPage extends React.Component<ITrainPageProps, ITrainPa
}

private showCheckboxPreview = (project: IProject) => {
if (project.tags.find((t) => t.type === FieldType.Checkbox)) {
if (project.tags.find((t) => t.type === FieldType.SelectionMark)) {
this.setState({
hasCheckbox: true,
});
Expand Down
4 changes: 0 additions & 4 deletions src/react/components/shell/skipButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ export interface ISkipButtonProps {

export class SkipButton extends React.Component<ISkipButtonProps> {

constructor(props: ISkipButtonProps) {
super(props);
}

public render() {
return (
<div className="skip-button">
Expand Down
9 changes: 8 additions & 1 deletion src/services/projectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ import { toast } from "react-toastify";
// tslint:disable-next-line:no-var-requires
const tagColors = require("../react/components/common/tagColors.json");

function normalizeFieldType(type: string): string {
if (type === "checkbox") {
return FieldType.SelectionMark;
}
return type;
}

/**
* Functions required for a project service
* @member save - Save a project
Expand Down Expand Up @@ -245,7 +252,7 @@ export default class ProjectService implements IProjectService {
tags.push({
name: field.fieldKey,
color: tagColors[index],
type: field.fieldType,
type: normalizeFieldType(field.fieldType),
format: field.fieldFormat,
} as ITag);
});
Expand Down

0 comments on commit f6c8ffa

Please sign in to comment.