aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deploy/assets/greencheck.pngbin0 -> 49332 bytes
-rw-r--r--deploy/assets/redx.pngbin0 -> 7353 bytes
-rw-r--r--src/client/documents/Documents.ts2
-rw-r--r--src/client/views/collections/CollectionSubView.tsx2
-rw-r--r--src/client/views/nodes/ImageBox.tsx21
5 files changed, 21 insertions, 4 deletions
diff --git a/deploy/assets/greencheck.png b/deploy/assets/greencheck.png
new file mode 100644
index 000000000..064e9def1
--- /dev/null
+++ b/deploy/assets/greencheck.png
Binary files differ
diff --git a/deploy/assets/redx.png b/deploy/assets/redx.png
new file mode 100644
index 000000000..0c2c9ccc5
--- /dev/null
+++ b/deploy/assets/redx.png
Binary files differ
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index ac643f91f..a7f939d7d 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -324,7 +324,7 @@ export namespace Docs {
// whatever options pertain to this specific prototype
const options = { title, type, baseProto: true, ...defaultOptions, ...(template.options || {}) };
options.layout = layout.view.LayoutString(layout.dataField);
- let doc = Doc.assign(new Doc(prototypeId, true), { layoutKey: "layout", ...options });
+ const doc = Doc.assign(new Doc(prototypeId, true), { layoutKey: "layout", ...options });
return doc;
}
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 80fcc33aa..321a6d34c 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -70,7 +70,7 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
(args) => {
const childLayout = Cast(this.props.Document.childLayout, Doc);
if (childLayout instanceof Doc) {
- this.childDocs.map(doc => Doc.ApplyTemplateTo(childLayout as Doc, doc, "layoutFromParent"));
+ this.childDocs.map(doc => Doc.ApplyTemplateTo(childLayout, doc, "layoutFromParent"));
}
else if (!(childLayout instanceof Promise)) {
this.childDocs.filter(d => !d.isTemplateForField).map(doc => doc.layoutKey === "layoutFromParent" && (doc.layoutKey = "layout"));
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index adec13e32..3f25faae6 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -58,6 +58,8 @@ declare class MediaRecorder {
type ImageDocument = makeInterface<[typeof pageSchema, typeof documentSchema]>;
const ImageDocument = makeInterface(pageSchema, documentSchema);
+const defaultUploadIcon = "downarrow.png";
+
@observer
export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocument>(ImageDocument) {
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(ImageBox, fieldKey); }
@@ -65,6 +67,7 @@ export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocum
private _dropDisposer?: DragManager.DragDropDisposer;
@observable private _audioState = 0;
@observable static _showControls: boolean;
+ @observable uploadIcon = defaultUploadIcon;
protected createDropTarget = (ele: HTMLDivElement) => {
this._dropDisposer && this._dropDisposer();
@@ -305,12 +308,26 @@ export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocum
return (
<img
id={"upload-icon"}
- src={"/assets/downarrow.png"}
+ src={`/assets/${this.uploadIcon}`}
onClick={async () => {
const { dataDoc } = this;
+ runInAction(() => this.uploadIcon = "loading.gif");
const [{ clientAccessPath }] = await Networking.PostToServer("/uploadRemoteImage", { sources: [primary] });
dataDoc.originalUrl = primary;
- dataDoc[this.props.fieldKey] = new ImageField(Utils.prepend(clientAccessPath));
+ let success = true;
+ let data: ImageField | undefined;
+ try {
+ data = new ImageField(clientAccessPath);
+ } catch {
+ success = false;
+ }
+ runInAction(() => this.uploadIcon = success ? "greencheck.png" : "redx.png");
+ setTimeout(action(() => {
+ this.uploadIcon = defaultUploadIcon;
+ if (data) {
+ dataDoc[this.props.fieldKey] = data;
+ }
+ }), 2000);
}}
/>
);