aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-07-27 12:29:46 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-07-27 12:29:46 -0400
commit0d32cf945d610898d9ff993b5b7e9775e84da68d (patch)
tree3725c480b612a8928a882be5e9e3799ed56cdb41
parentc360dc0adb468ae3aaa1c2d943606993d01a5a52 (diff)
added ctrl drop on images to set template. fixed stacking view autoHeight computation
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx4
-rw-r--r--src/client/views/nodes/ImageBox.tsx14
2 files changed, 14 insertions, 4 deletions
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index d5a7b90da..dab03f052 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -50,8 +50,8 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
() => {
if (this.singleColumn && BoolCast(this.props.Document.autoHeight)) {
let hgt = this.Sections.size * 50 + this.filteredChildren.reduce((height, d, i) => {
- let xhgt = height + this.getDocHeight(d) + (i === this.filteredChildren.length - 1 ? this.yMargin : this.gridGap);
- return xhgt;
+ let pair = Doc.GetLayoutDataDocPair(this.props.Document, this.props.DataDoc, this.props.fieldKey, d);
+ return height + this.getDocHeight(pair.layout) + (i === this.filteredChildren.length - 1 ? this.yMargin : this.gridGap);
}, this.yMargin);
(this.props.DataDoc && this.props.DataDoc.layout === this.layoutDoc ? this.props.DataDoc : this.layoutDoc)
.height = hgt * (this.props as any).ContentScaling();
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index a36885616..7e0d57e23 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -21,7 +21,7 @@ import { FieldView, FieldViewProps } from './FieldView';
import "./ImageBox.scss";
import React = require("react");
import { RouteStore } from '../../../server/RouteStore';
-import { Docs } from '../../documents/Documents';
+import { Docs, DocumentType } from '../../documents/Documents';
import { DocServer } from '../../DocServer';
import { Font } from '@react-pdf/renderer';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -85,10 +85,20 @@ export class ImageBox extends DocComponent<FieldViewProps, ImageDocument>(ImageD
@computed get extensionDoc() { return Doc.resolvedFieldDataDoc(this.dataDoc, this.props.fieldKey, "Alternates"); }
@undoBatch
+ @action
drop = (e: Event, de: DragManager.DropEvent) => {
if (de.data instanceof DragManager.DocumentDragData) {
de.data.droppedDocuments.forEach(action((drop: Doc) => {
- if (de.mods === "AltKey" && /*this.dataDoc !== this.props.Document &&*/ drop.data instanceof ImageField) {
+ if (de.mods === "CtrlKey") {
+ let temp = Doc.MakeDelegate(drop);
+ this.props.Document.nativeWidth = Doc.GetProto(this.props.Document).nativeWidth = undefined;
+ this.props.Document.nativeHeight = Doc.GetProto(this.props.Document).nativeHeight = undefined;
+ this.props.Document.width = drop.width;
+ this.props.Document.height = drop.height;
+ Doc.GetProto(this.props.Document).type = DocumentType.TEMPLATE;
+ this.props.Document.layout = temp;
+ e.stopPropagation();
+ } else if (de.mods === "AltKey" && /*this.dataDoc !== this.props.Document &&*/ drop.data instanceof ImageField) {
Doc.GetProto(this.dataDoc)[this.props.fieldKey] = new ImageField(drop.data.url);
e.stopPropagation();
} else if (de.mods === "CtrlKey") {