From ee4abbe72a0cc59e70be594c251091a2ac77fa8a Mon Sep 17 00:00:00 2001 From: Edward <sabinusedward@yahoo.de> Date: Thu, 11 Jun 2020 17:34:18 +0200 Subject: [PATCH] =?UTF-8?q?gitignore=20index.html;=20ShapeStyle=20hinzugef?= =?UTF-8?q?=C3=BCgt;=20bugs=20in=20Ellipse=20gefixt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + index.html | 1823 ++++++++++++++++++++++----------- src/Manager/ModalManager.elm | 51 +- src/Manager/UpdateManager.elm | 49 +- src/Manager/ViewManager.elm | 263 +++-- src/ShapePicture_Editor.elm | 9 +- src/TypeHolder.elm | 10 +- src/Util/ShapeManager.elm | 49 +- src/Util/Util.elm | 26 +- 9 files changed, 1552 insertions(+), 729 deletions(-) diff --git a/.gitignore b/.gitignore index 0509a27..cd1b592 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ elm-stuff/* +index.html diff --git a/index.html b/index.html index c21bd18..0812129 100644 --- a/index.html +++ b/index.html @@ -5339,6 +5339,7 @@ var $elm$core$Task$perform = F2( A2($elm$core$Task$map, toMessage, task))); }); var $elm$browser$Browser$application = _Browser_application; +var $author$project$Util$ShapeManager$Empty = {$: 'Empty'}; var $elm$json$Json$Encode$string = _Json_wrap; var $elm$html$Html$Attributes$stringProperty = F2( function (key, string) { @@ -5359,7 +5360,54 @@ var $elm$core$List$append = F2( var $elm$core$List$concat = function (lists) { return A3($elm$core$List$foldr, $elm$core$List$append, _List_Nil, lists); }; +var $author$project$Util$ShapeManager$ShapeStyle = function (hoveredFillColor) { + return function (hoveredFillOpacity) { + return function (hoveredStrokeColor) { + return function (hoveredStrokeWidth) { + return function (hoveredStrokeOpacity) { + return function (unHoveredFillColor) { + return function (unHoveredFillOpacity) { + return function (unHoveredStrokeColor) { + return function (unHoveredStrokeWidth) { + return function (unHoveredStrokeOpacity) { + return function (title) { + return function (body) { + return {body: body, hoveredFillColor: hoveredFillColor, hoveredFillOpacity: hoveredFillOpacity, hoveredStrokeColor: hoveredStrokeColor, hoveredStrokeOpacity: hoveredStrokeOpacity, hoveredStrokeWidth: hoveredStrokeWidth, title: title, unHoveredFillColor: unHoveredFillColor, unHoveredFillOpacity: unHoveredFillOpacity, unHoveredStrokeColor: unHoveredStrokeColor, unHoveredStrokeOpacity: unHoveredStrokeOpacity, unHoveredStrokeWidth: unHoveredStrokeWidth}; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +}; +var $author$project$Util$ShapeManager$defaultShapeStyle = $author$project$Util$ShapeManager$ShapeStyle('white')('0.5')('red')('3')('1.0')('white')('0.0')('red')('3')('1.0')('default')('default'); var $elm$html$Html$div = _VirtualDom_node('div'); +var $elm$core$List$drop = F2( + function (n, list) { + drop: + while (true) { + if (n <= 0) { + return list; + } else { + if (!list.b) { + return list; + } else { + var x = list.a; + var xs = list.b; + var $temp$n = n - 1, + $temp$list = xs; + n = $temp$n; + list = $temp$list; + continue drop; + } + } + } + }); var $author$project$Manager$ModalManager$NoModal = {$: 'NoModal'}; var $author$project$Manager$StateManager$getModalFromState = function (state) { switch (state.$) { @@ -5372,6 +5420,15 @@ var $author$project$Manager$StateManager$getModalFromState = function (state) { return $author$project$Manager$ModalManager$NoModal; } }; +var $elm$core$List$head = function (list) { + if (list.b) { + var x = list.a; + var xs = list.b; + return $elm$core$Maybe$Just(x); + } else { + return $elm$core$Maybe$Nothing; + } +}; var $elm$html$Html$Attributes$href = function (url) { return A2( $elm$html$Html$Attributes$stringProperty, @@ -5407,11 +5464,507 @@ var $author$project$Util$Util$link = F2( return A3($elm$html$Html$node, 'link', attributes, children); }); var $elm$html$Html$Attributes$rel = _VirtualDom_attribute('rel'); +var $elm$core$Tuple$second = function (_v0) { + var y = _v0.b; + return y; +}; var $elm$html$Html$section = _VirtualDom_node('section'); var $elm$virtual_dom$VirtualDom$style = _VirtualDom_style; var $elm$html$Html$Attributes$style = $elm$virtual_dom$VirtualDom$style; +var $elm$core$List$takeReverse = F3( + function (n, list, kept) { + takeReverse: + while (true) { + if (n <= 0) { + return kept; + } else { + if (!list.b) { + return kept; + } else { + var x = list.a; + var xs = list.b; + var $temp$n = n - 1, + $temp$list = xs, + $temp$kept = A2($elm$core$List$cons, x, kept); + n = $temp$n; + list = $temp$list; + kept = $temp$kept; + continue takeReverse; + } + } + } + }); +var $elm$core$List$takeTailRec = F2( + function (n, list) { + return $elm$core$List$reverse( + A3($elm$core$List$takeReverse, n, list, _List_Nil)); + }); +var $elm$core$List$takeFast = F3( + function (ctr, n, list) { + if (n <= 0) { + return _List_Nil; + } else { + var _v0 = _Utils_Tuple2(n, list); + _v0$1: + while (true) { + _v0$5: + while (true) { + if (!_v0.b.b) { + return list; + } else { + if (_v0.b.b.b) { + switch (_v0.a) { + case 1: + break _v0$1; + case 2: + var _v2 = _v0.b; + var x = _v2.a; + var _v3 = _v2.b; + var y = _v3.a; + return _List_fromArray( + [x, y]); + case 3: + if (_v0.b.b.b.b) { + var _v4 = _v0.b; + var x = _v4.a; + var _v5 = _v4.b; + var y = _v5.a; + var _v6 = _v5.b; + var z = _v6.a; + return _List_fromArray( + [x, y, z]); + } else { + break _v0$5; + } + default: + if (_v0.b.b.b.b && _v0.b.b.b.b.b) { + var _v7 = _v0.b; + var x = _v7.a; + var _v8 = _v7.b; + var y = _v8.a; + var _v9 = _v8.b; + var z = _v9.a; + var _v10 = _v9.b; + var w = _v10.a; + var tl = _v10.b; + return (ctr > 1000) ? A2( + $elm$core$List$cons, + x, + A2( + $elm$core$List$cons, + y, + A2( + $elm$core$List$cons, + z, + A2( + $elm$core$List$cons, + w, + A2($elm$core$List$takeTailRec, n - 4, tl))))) : A2( + $elm$core$List$cons, + x, + A2( + $elm$core$List$cons, + y, + A2( + $elm$core$List$cons, + z, + A2( + $elm$core$List$cons, + w, + A3($elm$core$List$takeFast, ctr + 1, n - 4, tl))))); + } else { + break _v0$5; + } + } + } else { + if (_v0.a === 1) { + break _v0$1; + } else { + break _v0$5; + } + } + } + } + return list; + } + var _v1 = _v0.b; + var x = _v1.a; + return _List_fromArray( + [x]); + } + }); +var $elm$core$List$take = F2( + function (n, list) { + return A3($elm$core$List$takeFast, 0, n, list); + }); var $elm$virtual_dom$VirtualDom$text = _VirtualDom_text; var $elm$html$Html$text = $elm$virtual_dom$VirtualDom$text; +var $author$project$TypeHolder$ManageModal = F2( + function (a, b) { + return {$: 'ManageModal', a: a, b: b}; + }); +var $author$project$TypeHolder$ManageShapes = F2( + function (a, b) { + return {$: 'ManageShapes', a: a, b: b}; + }); +var $author$project$Manager$ModalManager$OpenEditShape = F4( + function (a, b, c, d) { + return {$: 'OpenEditShape', a: a, b: b, c: c, d: d}; + }); +var $author$project$Util$ShapeManager$SaveEditedShape = F2( + function (a, b) { + return {$: 'SaveEditedShape', a: a, b: b}; + }); +var $elm$html$Html$button = _VirtualDom_node('button'); +var $elm$html$Html$Attributes$cols = function (n) { + return A2( + _VirtualDom_attribute, + 'cols', + $elm$core$String$fromInt(n)); +}; +var $author$project$Manager$ViewManager$modalCard = function (modalParts) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('modal is-active') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('modal-background') + ]), + _List_Nil), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('modal-card') + ]), + modalParts) + ])); +}; +var $author$project$Manager$ViewManager$modalCardStrongBody = F2( + function (attributes, children) { + return A2( + $elm$html$Html$section, + _Utils_ap( + _List_fromArray( + [ + $elm$html$Html$Attributes$class('modal-card-body') + ]), + attributes), + children); + }); +var $author$project$Manager$ViewManager$modalCardBody = function (bodyElements) { + return A2($author$project$Manager$ViewManager$modalCardStrongBody, _List_Nil, bodyElements); +}; +var $author$project$Manager$ModalManager$CloseModal = {$: 'CloseModal'}; +var $elm$html$Html$footer = _VirtualDom_node('footer'); +var $elm$core$String$fromFloat = _String_fromNumber; +var $elm$virtual_dom$VirtualDom$Normal = function (a) { + return {$: 'Normal', a: a}; +}; +var $elm$virtual_dom$VirtualDom$on = _VirtualDom_on; +var $elm$html$Html$Events$on = F2( + function (event, decoder) { + return A2( + $elm$virtual_dom$VirtualDom$on, + event, + $elm$virtual_dom$VirtualDom$Normal(decoder)); + }); +var $elm$html$Html$Events$onClick = function (msg) { + return A2( + $elm$html$Html$Events$on, + 'click', + $elm$json$Json$Decode$succeed(msg)); +}; +var $author$project$Manager$ViewManager$modalFooter = F2( + function (footElements, footElementsWidth) { + return A2( + $elm$html$Html$footer, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('modal-card-foot') + ]), + A2( + $elm$core$List$append, + footElements, + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button'), + A2( + $elm$html$Html$Attributes$style, + 'margin-left', + $elm$core$String$fromFloat(83.0 - footElementsWidth) + '%'), + $elm$html$Html$Events$onClick( + A2($author$project$TypeHolder$ManageModal, $author$project$Manager$ModalManager$CloseModal, '')) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Schließen') + ])) + ]))); + }); +var $elm$html$Html$header = _VirtualDom_node('header'); +var $elm$html$Html$p = _VirtualDom_node('p'); +var $author$project$Manager$ViewManager$modalStrongHeader = F2( + function (attributes, children) { + return A2( + $elm$html$Html$header, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('modal-card-head') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$p, + _Utils_ap( + _List_fromArray( + [ + $elm$html$Html$Attributes$class('modal-card-title') + ]), + attributes), + children), + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('delete aria-label=close'), + $elm$html$Html$Events$onClick( + A2($author$project$TypeHolder$ManageModal, $author$project$Manager$ModalManager$CloseModal, '')) + ]), + _List_Nil) + ])); + }); +var $author$project$Manager$ViewManager$modalHeader = function (title) { + return A2( + $author$project$Manager$ViewManager$modalStrongHeader, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(title) + ])); +}; +var $elm$html$Html$Events$alwaysStop = function (x) { + return _Utils_Tuple2(x, true); +}; +var $elm$virtual_dom$VirtualDom$MayStopPropagation = function (a) { + return {$: 'MayStopPropagation', a: a}; +}; +var $elm$html$Html$Events$stopPropagationOn = F2( + function (event, decoder) { + return A2( + $elm$virtual_dom$VirtualDom$on, + event, + $elm$virtual_dom$VirtualDom$MayStopPropagation(decoder)); + }); +var $elm$json$Json$Decode$field = _Json_decodeField; +var $elm$json$Json$Decode$at = F2( + function (fields, decoder) { + return A3($elm$core$List$foldr, $elm$json$Json$Decode$field, decoder, fields); + }); +var $elm$json$Json$Decode$string = _Json_decodeString; +var $elm$html$Html$Events$targetValue = A2( + $elm$json$Json$Decode$at, + _List_fromArray( + ['target', 'value']), + $elm$json$Json$Decode$string); +var $elm$html$Html$Events$onInput = function (tagger) { + return A2( + $elm$html$Html$Events$stopPropagationOn, + 'input', + A2( + $elm$json$Json$Decode$map, + $elm$html$Html$Events$alwaysStop, + A2($elm$json$Json$Decode$map, tagger, $elm$html$Html$Events$targetValue))); +}; +var $elm$json$Json$Encode$bool = _Json_wrap; +var $elm$html$Html$Attributes$boolProperty = F2( + function (key, bool) { + return A2( + _VirtualDom_property, + key, + $elm$json$Json$Encode$bool(bool)); + }); +var $elm$html$Html$Attributes$readonly = $elm$html$Html$Attributes$boolProperty('readOnly'); +var $elm$html$Html$Attributes$rows = function (n) { + return A2( + _VirtualDom_attribute, + 'rows', + $elm$core$String$fromInt(n)); +}; +var $author$project$Util$ShapeManager$DeleteShape = function (a) { + return {$: 'DeleteShape', a: a}; +}; +var $author$project$Manager$ViewManager$shapeDeleteButton = F2( + function (id, size) { + return A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-danger is-size-' + size), + $elm$html$Html$Events$onClick( + A2( + $author$project$TypeHolder$ManageShapes, + $author$project$Util$ShapeManager$DeleteShape(id), + '')) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Form löschen') + ])); + }); +var $elm$html$Html$table = _VirtualDom_node('table'); +var $elm$html$Html$td = _VirtualDom_node('td'); +var $elm$html$Html$textarea = _VirtualDom_node('textarea'); +var $elm$html$Html$th = _VirtualDom_node('th'); +var $elm$html$Html$tr = _VirtualDom_node('tr'); +var $author$project$Manager$ViewManager$viewEditShapeModal = F2( + function (id, shapeStyle) { + return (id <= 0) ? A2($elm$html$Html$div, _List_Nil, _List_Nil) : $author$project$Manager$ViewManager$modalCard( + _List_fromArray( + [ + $author$project$Manager$ViewManager$modalHeader( + 'Form ' + (((shapeStyle.title === 'default') ? $elm$core$String$fromInt(id) : shapeStyle.title) + ' bearbeiten')), + $author$project$Manager$ViewManager$modalCardBody( + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('control') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$table, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('table') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$tr, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$th, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('Optionen') + ])), + A2( + $elm$html$Html$th, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('Werte') + ])) + ])), + A2( + $elm$html$Html$tr, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$textarea, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('textarea has-fixed-size is-medium'), + $elm$html$Html$Attributes$rows(10), + $elm$html$Html$Attributes$cols(20), + $elm$html$Html$Attributes$readonly(true) + ]), + _List_fromArray( + [ + $elm$html$Html$text('hoveredFillColor \n'), + $elm$html$Html$text('hoveredFillOpacity \n'), + $elm$html$Html$text('hoveredStrokeColor \n'), + $elm$html$Html$text('hoveredStrokeWidth \n'), + $elm$html$Html$text('hoveredStrokeOpacity\n'), + $elm$html$Html$text('unHoveredFillColor \n'), + $elm$html$Html$text('unHoveredFillOpacity\n'), + $elm$html$Html$text('unHoveredStrokeColor\n'), + $elm$html$Html$text('unHoveredStrokeWidth\n'), + $elm$html$Html$text('unHoveredStrokeOpacity') + ])) + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$textarea, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('textarea has-fixed-size is-medium'), + $elm$html$Html$Attributes$rows(10), + $elm$html$Html$Attributes$cols(10), + $elm$html$Html$Events$onInput( + $author$project$TypeHolder$ManageModal( + A4($author$project$Manager$ModalManager$OpenEditShape, id, shapeStyle, 'TA', ''))) + ]), + _List_fromArray( + [ + $elm$html$Html$text(shapeStyle.hoveredFillColor + '\n'), + $elm$html$Html$text(shapeStyle.hoveredFillOpacity + '\n'), + $elm$html$Html$text(shapeStyle.hoveredStrokeColor + '\n'), + $elm$html$Html$text(shapeStyle.hoveredStrokeWidth + '\n'), + $elm$html$Html$text(shapeStyle.hoveredStrokeOpacity + '\n'), + $elm$html$Html$text(shapeStyle.unHoveredFillColor + '\n'), + $elm$html$Html$text(shapeStyle.unHoveredFillOpacity + '\n'), + $elm$html$Html$text(shapeStyle.unHoveredStrokeColor + '\n'), + $elm$html$Html$text(shapeStyle.unHoveredStrokeWidth + '\n'), + $elm$html$Html$text(shapeStyle.unHoveredStrokeOpacity) + ])) + ])) + ])) + ])) + ])) + ])), + A2( + $author$project$Manager$ViewManager$modalFooter, + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-success'), + $elm$html$Html$Events$onClick( + A2( + $author$project$TypeHolder$ManageShapes, + A2($author$project$Util$ShapeManager$SaveEditedShape, id, shapeStyle), + '')) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Speichern') + ])), + A2($author$project$Manager$ViewManager$shapeDeleteButton, id, '6') + ]), + 41.1) + ])); + }); var $author$project$Util$ShapeManager$AddShape = function (a) { return {$: 'AddShape', a: a}; }; @@ -5419,22 +5972,13 @@ var $author$project$Util$ShapeManager$Circle = F3( function (a, b, c) { return {$: 'Circle', a: a, b: b, c: c}; }); -var $author$project$Manager$ModalManager$CloseModal = {$: 'CloseModal'}; var $author$project$Util$ShapeManager$Ellipse = F4( function (a, b, c, d) { return {$: 'Ellipse', a: a, b: b, c: c, d: d}; }); -var $author$project$Util$ShapeManager$Empty = {$: 'Empty'}; var $author$project$TypeHolder$LoadShapes = function (a) { return {$: 'LoadShapes', a: a}; }; -var $author$project$TypeHolder$ManageModal = F2( - function (a, b) { - return {$: 'ManageModal', a: a, b: b}; - }); -var $author$project$TypeHolder$ManageShapes = function (a) { - return {$: 'ManageShapes', a: a}; -}; var $author$project$TypeHolder$OpenDrawShape = function (a) { return {$: 'OpenDrawShape', a: a}; }; @@ -5448,7 +5992,6 @@ var $author$project$Util$ShapeManager$Rectangle = F4( return {$: 'Rectangle', a: a, b: b, c: c, d: d}; }); var $elm$html$Html$a = _VirtualDom_node('a'); -var $elm$html$Html$button = _VirtualDom_node('button'); var $author$project$Util$ShapeManager$shapeNameToString = function (shape) { switch (shape.$) { case 'Empty': @@ -5495,6 +6038,8 @@ var $author$project$Manager$ModalManager$getInputShapeFromModal = function (moda case 'ShowInput': var shape = modal.a; return shape; + case 'ShowShape': + return $author$project$Util$ShapeManager$Empty; default: return $author$project$Util$ShapeManager$Empty; } @@ -5512,23 +6057,6 @@ var $author$project$Manager$StateManager$getInputShapeFromState = function (stat } }; var $elm$html$Html$h1 = _VirtualDom_node('h1'); -var $elm$virtual_dom$VirtualDom$Normal = function (a) { - return {$: 'Normal', a: a}; -}; -var $elm$virtual_dom$VirtualDom$on = _VirtualDom_on; -var $elm$html$Html$Events$on = F2( - function (event, decoder) { - return A2( - $elm$virtual_dom$VirtualDom$on, - event, - $elm$virtual_dom$VirtualDom$Normal(decoder)); - }); -var $elm$html$Html$Events$onClick = function (msg) { - return A2( - $elm$html$Html$Events$on, - 'click', - $elm$json$Json$Decode$succeed(msg)); -}; var $author$project$Util$ShapeManager$shapeNameStringToGerman = function (shape) { switch (shape) { case 'Circle': @@ -5746,8 +6274,10 @@ var $author$project$Manager$ViewManager$viewHeader_Buttons = function (state) { [ $elm$html$Html$Attributes$class('dropdown-item'), $elm$html$Html$Events$onClick( - $author$project$TypeHolder$ManageShapes( - $author$project$Util$ShapeManager$AddShape($author$project$Util$ShapeManager$Empty))), + A2( + $author$project$TypeHolder$ManageShapes, + $author$project$Util$ShapeManager$AddShape($author$project$Util$ShapeManager$Empty), + '')), $elm$html$Html$Attributes$href('') ]), _List_fromArray( @@ -5904,26 +6434,22 @@ var $elm$core$Basics$negate = function (n) { return -n; }; var $author$project$Util$Util$manageEllipseCoords = function (coords) { - var y = $author$project$Util$Util$stringToInt(coords.y); - var x = $author$project$Util$Util$stringToInt(coords.x); - var w = $author$project$Util$Util$stringToInt(coords.w); - var h = $author$project$Util$Util$stringToInt(coords.h); - return (w > 0) ? ((h > 0) ? coords : { - h: $elm$core$String$fromInt(-h), - w: $elm$core$String$fromInt(w), - x: $elm$core$String$fromInt(x), - y: $elm$core$String$fromInt(y) - }) : ((h > 0) ? { - h: $elm$core$String$fromInt(h), - w: $elm$core$String$fromInt(-w), - x: $elm$core$String$fromInt(x), - y: $elm$core$String$fromInt(y) - } : { - h: $elm$core$String$fromInt(-h), - w: $elm$core$String$fromInt(-w), - x: $elm$core$String$fromInt(x), - y: $elm$core$String$fromInt(y) - }); + var ry = $author$project$Util$Util$stringToInt(coords.ry); + var rx = $author$project$Util$Util$stringToInt(coords.rx); + return (rx > 0) ? ((ry > 0) ? coords : _Utils_update( + coords, + { + ry: $elm$core$String$fromInt(-ry) + })) : ((ry > 0) ? _Utils_update( + coords, + { + rx: $elm$core$String$fromInt(-rx) + }) : _Utils_update( + coords, + { + rx: $elm$core$String$fromInt(-rx), + ry: $elm$core$String$fromInt(-ry) + })); }; var $author$project$Util$Util$manageRectCoords = function (coords) { var y = $author$project$Util$Util$stringToInt(coords.y); @@ -5957,7 +6483,6 @@ var $author$project$Util$Util$MousePosition = F2( function (x, y) { return {x: x, y: y}; }); -var $elm$json$Json$Decode$field = _Json_decodeField; var $elm$json$Json$Decode$int = _Json_decodeInt; var $author$project$Util$Util$offsetMousePosition = A3( $elm$json$Json$Decode$map2, @@ -5977,10 +6502,6 @@ var $elm$svg$Svg$Attributes$r = _VirtualDom_attribute('r'); var $elm$svg$Svg$rect = $elm$svg$Svg$trustedNode('rect'); var $elm$svg$Svg$Attributes$rx = _VirtualDom_attribute('rx'); var $elm$svg$Svg$Attributes$ry = _VirtualDom_attribute('ry'); -var $elm$core$Tuple$second = function (_v0) { - var y = _v0.b; - return y; -}; var $author$project$Util$ShapeManager$shapeCoordsToString = function (shape) { switch (shape.$) { case 'Empty': @@ -6060,11 +6581,56 @@ var $author$project$Util$ShapeManager$shapeCoordsToHtmlCoords = function (shape) }; var $elm$svg$Svg$Attributes$style = _VirtualDom_attribute('style'); var $elm$svg$Svg$svg = $elm$svg$Svg$trustedNode('svg'); +var $elm$url$Url$addPort = F2( + function (maybePort, starter) { + if (maybePort.$ === 'Nothing') { + return starter; + } else { + var port_ = maybePort.a; + return starter + (':' + $elm$core$String$fromInt(port_)); + } + }); +var $elm$url$Url$addPrefixed = F3( + function (prefix, maybeSegment, starter) { + if (maybeSegment.$ === 'Nothing') { + return starter; + } else { + var segment = maybeSegment.a; + return _Utils_ap( + starter, + _Utils_ap(prefix, segment)); + } + }); +var $elm$url$Url$toString = function (url) { + var http = function () { + var _v0 = url.protocol; + if (_v0.$ === 'Http') { + return 'http://'; + } else { + return 'https://'; + } + }(); + return A3( + $elm$url$Url$addPrefixed, + '#', + url.fragment, + A3( + $elm$url$Url$addPrefixed, + '?', + url.query, + _Utils_ap( + A2( + $elm$url$Url$addPort, + url.port_, + _Utils_ap(http, url.host)), + url.path))); +}; var $elm$svg$Svg$Attributes$version = _VirtualDom_attribute('version'); var $elm$svg$Svg$Attributes$viewBox = _VirtualDom_attribute('viewBox'); -var $author$project$Manager$ModalManager$OpenShowShape = function (a) { - return {$: 'OpenShowShape', a: a}; -}; +var $author$project$Manager$ModalManager$OpenShowShape = F2( + function (a, b) { + return {$: 'OpenShowShape', a: a, b: b}; + }); var $author$project$TypeHolder$SvgShapeHover = function (a) { return {$: 'SvgShapeHover', a: a}; }; @@ -6083,26 +6649,41 @@ var $elm$svg$Svg$Events$onMouseOver = function (msg) { $elm$json$Json$Decode$succeed(msg)); }; var $elm$svg$Svg$Attributes$stroke = _VirtualDom_attribute('stroke'); +var $elm$svg$Svg$Attributes$strokeOpacity = _VirtualDom_attribute('stroke-opacity'); var $elm$svg$Svg$Attributes$strokeWidth = _VirtualDom_attribute('stroke-width'); -var $author$project$Manager$ViewManager$svgShapeStyle = F2( - function (activeShape, id) { - return _List_fromArray( - [ - $elm$svg$Svg$Attributes$fill('white'), - $elm$svg$Svg$Attributes$fillOpacity( - _Utils_eq(activeShape, id) ? '0.5' : '0.0'), - $elm$svg$Svg$Attributes$stroke('red'), - $elm$svg$Svg$Attributes$strokeWidth('3'), - $elm$svg$Svg$Events$onMouseOver( - $author$project$TypeHolder$SvgShapeHover(id)), - $elm$svg$Svg$Events$onMouseOut( - $author$project$TypeHolder$SvgShapeHover(0)), - $elm$svg$Svg$Events$onClick( - A2( - $author$project$TypeHolder$ManageModal, - $author$project$Manager$ModalManager$OpenShowShape(id), - '')) - ]); +var $author$project$Manager$ViewManager$svgShapeStyle = F3( + function (shapeStyle, activeShape, id) { + return $elm$core$List$concat( + _List_fromArray( + [ + _Utils_eq(activeShape, id) ? _List_fromArray( + [ + $elm$svg$Svg$Attributes$fill(shapeStyle.hoveredFillColor), + $elm$svg$Svg$Attributes$fillOpacity(shapeStyle.hoveredFillOpacity), + $elm$svg$Svg$Attributes$stroke(shapeStyle.hoveredStrokeColor), + $elm$svg$Svg$Attributes$strokeWidth(shapeStyle.hoveredStrokeWidth), + $elm$svg$Svg$Attributes$strokeOpacity(shapeStyle.hoveredStrokeOpacity) + ]) : _List_fromArray( + [ + $elm$svg$Svg$Attributes$fill(shapeStyle.unHoveredFillColor), + $elm$svg$Svg$Attributes$fillOpacity(shapeStyle.unHoveredFillOpacity), + $elm$svg$Svg$Attributes$stroke(shapeStyle.unHoveredStrokeColor), + $elm$svg$Svg$Attributes$strokeWidth(shapeStyle.unHoveredStrokeWidth), + $elm$svg$Svg$Attributes$strokeOpacity(shapeStyle.unHoveredStrokeOpacity) + ]), + _List_fromArray( + [ + $elm$svg$Svg$Events$onMouseOver( + $author$project$TypeHolder$SvgShapeHover(id)), + $elm$svg$Svg$Events$onMouseOut( + $author$project$TypeHolder$SvgShapeHover(0)), + $elm$svg$Svg$Events$onClick( + A2( + $author$project$TypeHolder$ManageModal, + A2($author$project$Manager$ModalManager$OpenShowShape, id, 0), + '')) + ]) + ])); }); var $elm$svg$Svg$Attributes$width = _VirtualDom_attribute('width'); var $elm$svg$Svg$Attributes$x = _VirtualDom_attribute('x'); @@ -6117,13 +6698,15 @@ var $author$project$Manager$ViewManager$viewSvgShapes = F3( return A2( $elm$core$List$cons, function () { - switch (x.$) { + var s = x.b; + var f = x.a; + switch (f.$) { case 'Empty': return A2($elm$svg$Svg$rect, _List_Nil, _List_Nil); case 'Circle': - var a = x.a; - var b = x.b; - var c = x.c; + var a = f.a; + var b = f.b; + var c = f.c; return A2( $elm$svg$Svg$circle, _Utils_ap( @@ -6133,13 +6716,13 @@ var $author$project$Manager$ViewManager$viewSvgShapes = F3( $elm$svg$Svg$Attributes$cy(b), $elm$svg$Svg$Attributes$r(c) ]), - A2($author$project$Manager$ViewManager$svgShapeStyle, activeShape, id)), + A3($author$project$Manager$ViewManager$svgShapeStyle, s, activeShape, id)), _List_Nil); case 'Rectangle': - var a = x.a; - var b = x.b; - var c = x.c; - var d = x.d; + var a = f.a; + var b = f.b; + var c = f.c; + var d = f.d; return A2( $elm$svg$Svg$rect, _Utils_ap( @@ -6150,13 +6733,13 @@ var $author$project$Manager$ViewManager$viewSvgShapes = F3( $elm$svg$Svg$Attributes$width(c), $elm$svg$Svg$Attributes$height(d) ]), - A2($author$project$Manager$ViewManager$svgShapeStyle, activeShape, id)), + A3($author$project$Manager$ViewManager$svgShapeStyle, s, activeShape, id)), _List_Nil); case 'Ellipse': - var a = x.a; - var b = x.b; - var c = x.c; - var d = x.d; + var a = f.a; + var b = f.b; + var c = f.c; + var d = f.d; return A2( $elm$svg$Svg$ellipse, _Utils_ap( @@ -6167,19 +6750,19 @@ var $author$project$Manager$ViewManager$viewSvgShapes = F3( $elm$svg$Svg$Attributes$rx(c), $elm$svg$Svg$Attributes$ry(d) ]), - A2($author$project$Manager$ViewManager$svgShapeStyle, activeShape, id)), + A3($author$project$Manager$ViewManager$svgShapeStyle, s, activeShape, id)), _List_Nil); default: - var pointList = x.a; + var pointList = f.a; return A2( $elm$svg$Svg$polygon, _Utils_ap( _List_fromArray( [ $elm$svg$Svg$Attributes$points( - $author$project$Util$ShapeManager$shapeCoordsToHtmlCoords(x)) + $author$project$Util$ShapeManager$shapeCoordsToHtmlCoords(f)) ]), - A2($author$project$Manager$ViewManager$svgShapeStyle, activeShape, id)), + A3($author$project$Manager$ViewManager$svgShapeStyle, s, activeShape, id)), _List_Nil); } }(), @@ -6235,7 +6818,8 @@ var $author$project$Manager$ViewManager$viewImage = function (model) { [ $elm$svg$Svg$Attributes$width('800'), $elm$svg$Svg$Attributes$height('600'), - $elm$svg$Svg$Attributes$xlinkHref('http://www.informatik.uni-halle.de/im/1285058520_1381_00_800.jpg') + $elm$svg$Svg$Attributes$xlinkHref( + $elm$url$Url$toString(model.pictureUrl)) ]), _List_Nil) ]), @@ -6301,25 +6885,25 @@ var $author$project$Manager$ViewManager$viewImage = function (model) { } else { var coords = $author$project$Util$Util$manageEllipseCoords( { - h: A2( - $author$project$Util$Util$abstand1D, - mPos.y, - $author$project$Util$Util$stringToInt(b)), - w: A2( + cx: a, + cy: b, + rx: A2( $author$project$Util$Util$abstand1D, mPos.x, $author$project$Util$Util$stringToInt(a)), - x: a, - y: b + ry: A2( + $author$project$Util$Util$abstand1D, + mPos.y, + $author$project$Util$Util$stringToInt(b)) }); return A2( $elm$svg$Svg$ellipse, _List_fromArray( [ - $elm$svg$Svg$Attributes$cx(coords.x), - $elm$svg$Svg$Attributes$cy(coords.y), - $elm$svg$Svg$Attributes$rx(coords.w), - $elm$svg$Svg$Attributes$ry(coords.h) + $elm$svg$Svg$Attributes$cx(coords.cx), + $elm$svg$Svg$Attributes$cy(coords.cy), + $elm$svg$Svg$Attributes$rx(coords.rx), + $elm$svg$Svg$Attributes$ry(coords.ry) ]), _List_Nil); } @@ -6398,186 +6982,56 @@ var $author$project$Manager$ViewManager$viewImage = function (model) { _List_Nil); } else { var p = pList.a; - var ps = pList.b; - return A2( - $elm$svg$Svg$polygon, - _List_fromArray( - [ - $elm$svg$Svg$Attributes$points( - $author$project$Util$ShapeManager$shapeCoordsToHtmlCoords( - $author$project$Util$ShapeManager$Polygon( - A2( - $elm$core$List$cons, - _Utils_Tuple2( - $elm$core$String$fromInt(mPos.x), - $elm$core$String$fromInt(mPos.y)), - pList)))) - ]), - _List_Nil); - } - } - } - }(), - A2( - $elm$svg$Svg$rect, - _List_fromArray( - [ - $elm$svg$Svg$Attributes$x('0'), - $elm$svg$Svg$Attributes$y('0'), - $elm$svg$Svg$Attributes$width('800'), - $elm$svg$Svg$Attributes$height('600'), - $elm$svg$Svg$Attributes$style('fill:blue;stroke:pink;stroke-width:5;fill-opacity:0.1;stroke-opacity:0.9'), - $author$project$Util$Util$onMouseMove($author$project$TypeHolder$UpdateMousePos), - $elm$svg$Svg$Events$onClick($author$project$TypeHolder$InputDrawShape) - ]), - _List_Nil) - ]); - } - }() - ]))) - ])) - ])); -}; -var $author$project$Manager$ModalManager$Check = function (a) { - return {$: 'Check', a: a}; -}; -var $author$project$Manager$ModalManager$Input = F2( - function (a, b) { - return {$: 'Input', a: a, b: b}; - }); -var $author$project$Manager$ModalManager$InputPoint = {$: 'InputPoint'}; -var $elm$html$Html$input = _VirtualDom_node('input'); -var $elm$html$Html$label = _VirtualDom_node('label'); -var $author$project$Manager$ViewManager$modalCard = function (modalParts) { - return A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal is-active') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal-background') - ]), - _List_Nil), - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal-card') - ]), - modalParts) - ])); -}; -var $author$project$Manager$ViewManager$modalCardBody = function (bodyElements) { - return A2( - $elm$html$Html$section, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal-card-body') - ]), - bodyElements); -}; -var $elm$html$Html$footer = _VirtualDom_node('footer'); -var $author$project$Manager$ViewManager$modalFooter = F2( - function (footElements, footElementsWidth) { - return A2( - $elm$html$Html$footer, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal-card-foot') - ]), - A2( - $elm$core$List$append, - footElements, - _List_fromArray( - [ - A2( - $elm$html$Html$button, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('button'), - A2( - $elm$html$Html$Attributes$style, - 'margin-left', - $elm$core$String$fromInt(83 - footElementsWidth) + '%'), - $elm$html$Html$Events$onClick( - A2($author$project$TypeHolder$ManageModal, $author$project$Manager$ModalManager$CloseModal, '')) - ]), - _List_fromArray( - [ - $elm$html$Html$text('Schließen') - ])) - ]))); - }); -var $elm$html$Html$header = _VirtualDom_node('header'); -var $elm$html$Html$p = _VirtualDom_node('p'); -var $author$project$Manager$ViewManager$modalHeader = function (title) { - return A2( - $elm$html$Html$header, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal-card-head') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$p, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal-card-title') - ]), - _List_fromArray( - [ - $elm$html$Html$text(title) - ])), - A2( - $elm$html$Html$button, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('delete aria-label=close'), - $elm$html$Html$Events$onClick( - A2($author$project$TypeHolder$ManageModal, $author$project$Manager$ModalManager$CloseModal, '')) - ]), - _List_Nil) + var ps = pList.b; + return A2( + $elm$svg$Svg$polygon, + _List_fromArray( + [ + $elm$svg$Svg$Attributes$points( + $author$project$Util$ShapeManager$shapeCoordsToHtmlCoords( + $author$project$Util$ShapeManager$Polygon( + A2( + $elm$core$List$cons, + _Utils_Tuple2( + $elm$core$String$fromInt(mPos.x), + $elm$core$String$fromInt(mPos.y)), + pList)))) + ]), + _List_Nil); + } + } + } + }(), + A2( + $elm$svg$Svg$rect, + _List_fromArray( + [ + $elm$svg$Svg$Attributes$x('0'), + $elm$svg$Svg$Attributes$y('0'), + $elm$svg$Svg$Attributes$width('800'), + $elm$svg$Svg$Attributes$height('600'), + $elm$svg$Svg$Attributes$style('fill:blue;stroke:pink;stroke-width:5;fill-opacity:0.1;stroke-opacity:0.9'), + $author$project$Util$Util$onMouseMove($author$project$TypeHolder$UpdateMousePos), + $elm$svg$Svg$Events$onClick($author$project$TypeHolder$InputDrawShape) + ]), + _List_Nil) + ]); + } + }() + ]))) + ])) ])); }; -var $elm$html$Html$Events$alwaysStop = function (x) { - return _Utils_Tuple2(x, true); -}; -var $elm$virtual_dom$VirtualDom$MayStopPropagation = function (a) { - return {$: 'MayStopPropagation', a: a}; +var $author$project$Manager$ModalManager$Check = function (a) { + return {$: 'Check', a: a}; }; -var $elm$html$Html$Events$stopPropagationOn = F2( - function (event, decoder) { - return A2( - $elm$virtual_dom$VirtualDom$on, - event, - $elm$virtual_dom$VirtualDom$MayStopPropagation(decoder)); - }); -var $elm$json$Json$Decode$at = F2( - function (fields, decoder) { - return A3($elm$core$List$foldr, $elm$json$Json$Decode$field, decoder, fields); +var $author$project$Manager$ModalManager$Input = F2( + function (a, b) { + return {$: 'Input', a: a, b: b}; }); -var $elm$json$Json$Decode$string = _Json_decodeString; -var $elm$html$Html$Events$targetValue = A2( - $elm$json$Json$Decode$at, - _List_fromArray( - ['target', 'value']), - $elm$json$Json$Decode$string); -var $elm$html$Html$Events$onInput = function (tagger) { - return A2( - $elm$html$Html$Events$stopPropagationOn, - 'input', - A2( - $elm$json$Json$Decode$map, - $elm$html$Html$Events$alwaysStop, - A2($elm$json$Json$Decode$map, tagger, $elm$html$Html$Events$targetValue))); -}; +var $author$project$Manager$ModalManager$InputPoint = {$: 'InputPoint'}; +var $elm$html$Html$input = _VirtualDom_node('input'); +var $elm$html$Html$label = _VirtualDom_node('label'); var $elm$html$Html$Attributes$placeholder = $elm$html$Html$Attributes$stringProperty('placeholder'); var $elm$html$Html$Attributes$value = $elm$html$Html$Attributes$stringProperty('value'); var $author$project$Manager$ViewManager$viewNewShapeInputModal = F3( @@ -7174,52 +7628,181 @@ var $author$project$Manager$ViewManager$viewNewShapeInputModal = F3( [ $elm$html$Html$Attributes$class('button is-success'), $elm$html$Html$Events$onClick( - $author$project$TypeHolder$ManageShapes( - $author$project$Util$ShapeManager$AddShape($author$project$Util$ShapeManager$Empty))) + A2( + $author$project$TypeHolder$ManageShapes, + $author$project$Util$ShapeManager$AddShape($author$project$Util$ShapeManager$Empty), + '')) ]), _List_fromArray( [ $elm$html$Html$text('Form hinzufügen') ])) ]), - 27) + 27.0) ])); }); -var $author$project$Manager$ViewManager$viewShapeModal = function (id) { - return (id <= 0) ? A2($elm$html$Html$div, _List_Nil, _List_Nil) : $author$project$Manager$ViewManager$modalCard( - _List_fromArray( - [ - $author$project$Manager$ViewManager$modalHeader( - 'Form ' + $elm$core$String$fromInt(id)), - A2( - $elm$html$Html$section, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('modal-card-body') - ]), - _List_fromArray( - [ - $elm$html$Html$text( - 'Form ' + ($elm$core$String$fromInt(id) + ' wurde gefunden!')) - ])), - A2($author$project$Manager$ViewManager$modalFooter, _List_Nil, 0) - ])); +var $author$project$Util$ShapeManager$SaveShapeStyle = F4( + function (a, b, c, d) { + return {$: 'SaveShapeStyle', a: a, b: b, c: c, d: d}; + }); +var $elm$html$Html$iframe = _VirtualDom_node('iframe'); +var $elm$html$Html$Events$onDoubleClick = function (msg) { + return A2( + $elm$html$Html$Events$on, + 'dblclick', + $elm$json$Json$Decode$succeed(msg)); }; -var $elm$html$Html$table = _VirtualDom_node('table'); -var $elm$html$Html$th = _VirtualDom_node('th'); -var $elm$html$Html$tr = _VirtualDom_node('tr'); -var $author$project$Util$ShapeManager$DeleteShape = function (a) { - return {$: 'DeleteShape', a: a}; +var $elm$html$Html$Events$onMouseLeave = function (msg) { + return A2( + $elm$html$Html$Events$on, + 'mouseleave', + $elm$json$Json$Decode$succeed(msg)); +}; +var $author$project$Manager$ViewManager$shapeEditButton = F3( + function (id, shapeStyle, size) { + return A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-size-' + size), + $elm$html$Html$Events$onClick( + A2( + $author$project$TypeHolder$ManageModal, + A4($author$project$Manager$ModalManager$OpenEditShape, id, shapeStyle, '', ''), + '')) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Form bearbeiten') + ])); + }); +var $elm$html$Html$Attributes$src = function (url) { + return A2( + $elm$html$Html$Attributes$stringProperty, + 'src', + _VirtualDom_noJavaScriptOrHtmlUri(url)); }; +var $author$project$Manager$ViewManager$viewShapeModal = F3( + function (id, edit, shapeStyle) { + return (id <= 0) ? A2($elm$html$Html$div, _List_Nil, _List_Nil) : $author$project$Manager$ViewManager$modalCard( + _List_fromArray( + [ + A2( + $author$project$Manager$ViewManager$modalStrongHeader, + _List_fromArray( + [ + $elm$html$Html$Events$onDoubleClick( + A2( + $author$project$TypeHolder$ManageModal, + A2($author$project$Manager$ModalManager$OpenShowShape, id, 1), + '')), + $elm$html$Html$Events$onMouseLeave( + A2( + $author$project$TypeHolder$ManageModal, + A2($author$project$Manager$ModalManager$OpenShowShape, id, 0), + '')) + ]), + _List_fromArray( + [ + (edit === 1) ? A2( + $elm$html$Html$label, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$input, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('input'), + $elm$html$Html$Attributes$value(shapeStyle.title), + $elm$html$Html$Events$onInput( + $author$project$TypeHolder$ManageShapes( + A4($author$project$Util$ShapeManager$SaveShapeStyle, id, shapeStyle, 'T', ''))) + ]), + _List_Nil) + ])) : $elm$html$Html$text( + (shapeStyle.title === 'default') ? ('Form ' + $elm$core$String$fromInt(id)) : shapeStyle.title) + ])), + A2( + $author$project$Manager$ViewManager$modalCardStrongBody, + _List_fromArray( + [ + $elm$html$Html$Events$onDoubleClick( + A2( + $author$project$TypeHolder$ManageModal, + A2($author$project$Manager$ModalManager$OpenShowShape, id, 2), + '')), + $elm$html$Html$Events$onMouseLeave( + A2( + $author$project$TypeHolder$ManageModal, + A2($author$project$Manager$ModalManager$OpenShowShape, id, 0), + '')) + ]), + _List_fromArray( + [ + function () { + if (edit === 2) { + return A2( + $elm$html$Html$label, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$input, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('input'), + $elm$html$Html$Attributes$value(shapeStyle.body), + $elm$html$Html$Events$onInput( + $author$project$TypeHolder$ManageShapes( + A4($author$project$Util$ShapeManager$SaveShapeStyle, id, shapeStyle, 'B', ''))) + ]), + _List_Nil) + ])); + } else { + if (shapeStyle.body === 'default') { + return $elm$html$Html$text( + 'Form ' + ($elm$core$String$fromInt(id) + ' wurde gefunden!')); + } else { + var _v0 = $elm$url$Url$fromString(shapeStyle.body); + if (_v0.$ === 'Just') { + var url = _v0.a; + return A2( + $elm$html$Html$iframe, + _List_fromArray( + [ + $elm$html$Html$Attributes$src(shapeStyle.body), + A2($elm$html$Html$Attributes$style, 'width', '100%'), + A2($elm$html$Html$Attributes$style, 'height', '100%') + ]), + _List_Nil); + } else { + return $elm$html$Html$text(shapeStyle.body); + } + } + } + }() + ])), + A2( + $author$project$Manager$ViewManager$modalFooter, + _List_fromArray( + [ + A3($author$project$Manager$ViewManager$shapeEditButton, id, shapeStyle, '6'), + A2($author$project$Manager$ViewManager$shapeDeleteButton, id, '6') + ]), + 49.1) + ])); + }); var $elm$html$Html$Attributes$id = $elm$html$Html$Attributes$stringProperty('id'); -var $elm$html$Html$td = _VirtualDom_node('td'); var $author$project$Manager$ViewManager$writeShapeToTable = F2( - function (shapeList, id) { - if (!shapeList.b) { + function (shapes, id) { + if (!shapes.b) { return _List_Nil; } else { - var x = shapeList.a; - var xs = shapeList.b; + var x = shapes.a; + var xs = shapes.b; + var s = x.b; + var f = x.a; return A2( $elm$core$List$cons, A2( @@ -7237,7 +7820,7 @@ var $author$project$Manager$ViewManager$writeShapeToTable = F2( _List_fromArray( [ $elm$html$Html$text( - 'Form' + $elm$core$String$fromInt(id)) + (s.title === 'default') ? ('Form' + $elm$core$String$fromInt(id)) : s.title) ])), A2( $elm$html$Html$td, @@ -7246,7 +7829,7 @@ var $author$project$Manager$ViewManager$writeShapeToTable = F2( [ $elm$html$Html$text( $author$project$Util$ShapeManager$shapeNameStringToGerman( - $author$project$Util$ShapeManager$shapeNameToString(x))) + $author$project$Util$ShapeManager$shapeNameToString(f))) ])), A2( $elm$html$Html$td, @@ -7254,26 +7837,21 @@ var $author$project$Manager$ViewManager$writeShapeToTable = F2( _List_fromArray( [ $elm$html$Html$text( - $author$project$Util$ShapeManager$shapeCoordsToString(x)) + $author$project$Util$ShapeManager$shapeCoordsToString(f)) ])), A2( $elm$html$Html$td, _List_Nil, _List_fromArray( [ - A2( - $elm$html$Html$button, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('button is-danger is-size-7'), - $elm$html$Html$Events$onClick( - $author$project$TypeHolder$ManageShapes( - $author$project$Util$ShapeManager$DeleteShape(id))) - ]), - _List_fromArray( - [ - $elm$html$Html$text('Form löschen') - ])) + A2($author$project$Manager$ViewManager$shapeDeleteButton, id, '7') + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + A3($author$project$Manager$ViewManager$shapeEditButton, id, s, '7') ])) ])), A2($author$project$Manager$ViewManager$writeShapeToTable, xs, id + 1)); @@ -7316,7 +7894,7 @@ var $author$project$Manager$ViewManager$viewTableModal = function (modelSaved) { _List_Nil, _List_fromArray( [ - $elm$html$Html$text('ID') + $elm$html$Html$text('Name/ID') ])), A2( $elm$html$Html$th, @@ -7335,6 +7913,13 @@ var $author$project$Manager$ViewManager$viewTableModal = function (modelSaved) { A2( $elm$html$Html$th, _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('') + ])), + A2( + $elm$html$Html$th, + _List_Nil, _List_fromArray( [ $elm$html$Html$text('') @@ -7421,11 +8006,30 @@ var $author$project$Manager$ViewManager$view = function (model) { [ $author$project$Manager$ViewManager$viewTableModal(model.saved) ]); + case 'ShowShape': + var id = _v1.a; + var edit = _v1.b; + return _List_fromArray( + [ + A3( + $author$project$Manager$ViewManager$viewShapeModal, + id, + edit, + A2( + $elm$core$Maybe$withDefault, + _Utils_Tuple2($author$project$Util$ShapeManager$Empty, $author$project$Util$ShapeManager$defaultShapeStyle), + $elm$core$List$head( + A2( + $elm$core$List$drop, + id - 1, + A2($elm$core$List$take, id, model.saved)))).b) + ]); default: var id = _v1.a; + var shapeStyle = _v1.b; return _List_fromArray( [ - $author$project$Manager$ViewManager$viewShapeModal(id) + A2($author$project$Manager$ViewManager$viewEditShapeModal, id, shapeStyle) ]); } }() @@ -7440,9 +8044,9 @@ var $author$project$ShapePicture_Editor$documentView = function (model) { title: 'ShapePicture_Editor' }; }; -var $author$project$TypeHolder$Model = F6( - function (state, saved, svgShapeHover, shapesLoadResult, url, key) { - return {key: key, saved: saved, shapesLoadResult: shapesLoadResult, state: state, svgShapeHover: svgShapeHover, url: url}; +var $author$project$TypeHolder$Model = F7( + function (state, saved, svgShapeHover, shapesLoadResult, pictureUrl, url, key) { + return {key: key, pictureUrl: pictureUrl, saved: saved, shapesLoadResult: shapesLoadResult, state: state, svgShapeHover: svgShapeHover, url: url}; }); var $author$project$Manager$StateManager$Standby = {$: 'Standby'}; var $elm$core$Platform$Cmd$batch = _Platform_batch; @@ -7450,12 +8054,13 @@ var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil); var $author$project$ShapePicture_Editor$init = F3( function (_v0, url, key) { return _Utils_Tuple2( - A6( + A7( $author$project$TypeHolder$Model, $author$project$Manager$StateManager$Standby, _List_Nil, 0, $elm$core$Result$Ok(' Init'), + A6($elm$url$Url$Url, $elm$url$Url$Http, 'www.informatik.uni-halle.de', $elm$core$Maybe$Nothing, '/im/1285058520_1381_00_800.jpg', $elm$core$Maybe$Nothing, $elm$core$Maybe$Nothing), url, key), $elm$core$Platform$Cmd$none); @@ -8261,65 +8866,21 @@ var $elm$http$Http$get = function (r) { return $elm$http$Http$request( {body: $elm$http$Http$emptyBody, expect: r.expect, headers: _List_Nil, method: 'GET', timeout: $elm$core$Maybe$Nothing, tracker: $elm$core$Maybe$Nothing, url: r.url}); }; -var $elm$browser$Browser$Navigation$load = _Browser_load; -var $elm$browser$Browser$Navigation$pushUrl = _Browser_pushUrl; -var $elm$json$Json$Decode$list = _Json_decodeList; -var $elm$json$Json$Decode$map4 = _Json_map4; -var $author$project$Util$ShapeManager$rectListDecoder = A2( - $elm$json$Json$Decode$field, - 'rectangle', - $elm$json$Json$Decode$list( - A5( - $elm$json$Json$Decode$map4, - $author$project$Util$ShapeManager$Rectangle, - A2($elm$json$Json$Decode$field, 'x', $elm$json$Json$Decode$string), - A2($elm$json$Json$Decode$field, 'y', $elm$json$Json$Decode$string), - A2($elm$json$Json$Decode$field, 'width', $elm$json$Json$Decode$string), - A2($elm$json$Json$Decode$field, 'height', $elm$json$Json$Decode$string)))); -var $elm$url$Url$addPort = F2( - function (maybePort, starter) { - if (maybePort.$ === 'Nothing') { - return starter; - } else { - var port_ = maybePort.a; - return starter + (':' + $elm$core$String$fromInt(port_)); - } - }); -var $elm$url$Url$addPrefixed = F3( - function (prefix, maybeSegment, starter) { - if (maybeSegment.$ === 'Nothing') { - return starter; - } else { - var segment = maybeSegment.a; - return _Utils_ap( - starter, - _Utils_ap(prefix, segment)); - } - }); -var $elm$url$Url$toString = function (url) { - var http = function () { - var _v0 = url.protocol; - if (_v0.$ === 'Http') { - return 'http://'; - } else { - return 'https://'; - } - }(); - return A3( - $elm$url$Url$addPrefixed, - '#', - url.fragment, - A3( - $elm$url$Url$addPrefixed, - '?', - url.query, - _Utils_ap( - A2( - $elm$url$Url$addPort, - url.port_, - _Utils_ap(http, url.host)), - url.path))); -}; +var $elm$browser$Browser$Navigation$load = _Browser_load; +var $elm$browser$Browser$Navigation$pushUrl = _Browser_pushUrl; +var $elm$json$Json$Decode$list = _Json_decodeList; +var $elm$json$Json$Decode$map4 = _Json_map4; +var $author$project$Util$ShapeManager$rectListDecoder = A2( + $elm$json$Json$Decode$field, + 'rectangle', + $elm$json$Json$Decode$list( + A5( + $elm$json$Json$Decode$map4, + $author$project$Util$ShapeManager$Rectangle, + A2($elm$json$Json$Decode$field, 'x', $elm$json$Json$Decode$string), + A2($elm$json$Json$Decode$field, 'y', $elm$json$Json$Decode$string), + A2($elm$json$Json$Decode$field, 'width', $elm$json$Json$Decode$string), + A2($elm$json$Json$Decode$field, 'height', $elm$json$Json$Decode$string)))); var $author$project$Manager$UpdateManager$updateCmdMsg = F2( function (msg, model) { updateCmdMsg: @@ -8400,8 +8961,10 @@ var $author$project$Manager$ModalManager$modalNameToString = function (modal) { return 'ShowTable'; case 'ShowInput': return 'ShowInput'; - default: + case 'ShowShape': return 'ShowShape'; + default: + return 'EditShape'; } }; var $author$project$Manager$ModalManager$eq_String_Modal = F2( @@ -8420,6 +8983,37 @@ var $elm$core$Tuple$pair = F2( function (a, b) { return _Utils_Tuple2(a, b); }); +var $elm$core$List$repeatHelp = F3( + function (result, n, value) { + repeatHelp: + while (true) { + if (n <= 0) { + return result; + } else { + var $temp$result = A2($elm$core$List$cons, value, result), + $temp$n = n - 1, + $temp$value = value; + result = $temp$result; + n = $temp$n; + value = $temp$value; + continue repeatHelp; + } + } + }); +var $elm$core$List$repeat = F2( + function (n, value) { + return A3($elm$core$List$repeatHelp, _List_Nil, n, value); + }); +var $author$project$Util$ShapeManager$shapeListToShape_ShapeStyleList = function (shapes) { + return A3( + $elm$core$List$map2, + $elm$core$Tuple$pair, + shapes, + A2( + $elm$core$List$repeat, + $elm$core$List$length(shapes), + $author$project$Util$ShapeManager$defaultShapeStyle)); +}; var $author$project$Util$ShapeManager$shapesDecoderList = F3( function (shape, _var, s) { var res = A2( @@ -8527,13 +9121,18 @@ var $author$project$Util$ShapeManager$shapesDecoder = function (s) { ]) : _List_Nil ])); }; +var $author$project$Manager$ModalManager$EditShape = F2( + function (a, b) { + return {$: 'EditShape', a: a, b: b}; + }); var $author$project$Manager$ModalManager$ShowInput = F3( function (a, b, c) { return {$: 'ShowInput', a: a, b: b, c: c}; }); -var $author$project$Manager$ModalManager$ShowShape = function (a) { - return {$: 'ShowShape', a: a}; -}; +var $author$project$Manager$ModalManager$ShowShape = F2( + function (a, b) { + return {$: 'ShowShape', a: a, b: b}; + }); var $author$project$Manager$ModalManager$ShowTable = {$: 'ShowTable'}; var $author$project$Util$ShapeManager$deleteCoordsFromShape = function (shape) { switch (shape.$) { @@ -8752,7 +9351,76 @@ var $author$project$Manager$ModalManager$updateModal = F2( return A2($author$project$Manager$ModalManager$eq_String_Modal, 'ShowInput', modal) ? $author$project$Manager$ModalManager$NoModal : A3($author$project$Manager$ModalManager$ShowInput, $author$project$Util$ShapeManager$Empty, '', ''); case 'OpenShowShape': var id = msg.a; - return (id <= 0) ? $author$project$Manager$ModalManager$NoModal : $author$project$Manager$ModalManager$ShowShape(id); + var edit = msg.b; + return (id <= 0) ? $author$project$Manager$ModalManager$NoModal : A2($author$project$Manager$ModalManager$ShowShape, id, edit); + case 'OpenEditShape': + var id = msg.a; + var shapeStyle = msg.b; + var inputType = msg.c; + var value = msg.d; + return (id <= 0) ? $author$project$Manager$ModalManager$NoModal : A2( + $author$project$Manager$ModalManager$EditShape, + id, + function () { + if (inputType === 'TA') { + var values = A2($elm$core$String$split, '\n', value); + return ($elm$core$List$length(values) === 10) ? _Utils_update( + shapeStyle, + { + hoveredFillColor: A2( + $elm$core$Maybe$withDefault, + 'white', + $elm$core$List$head(values)), + hoveredFillOpacity: A2( + $elm$core$Maybe$withDefault, + '0.5', + $elm$core$List$head( + A2($elm$core$List$drop, 1, values))), + hoveredStrokeColor: A2( + $elm$core$Maybe$withDefault, + 'red', + $elm$core$List$head( + A2($elm$core$List$drop, 2, values))), + hoveredStrokeOpacity: A2( + $elm$core$Maybe$withDefault, + '1.0', + $elm$core$List$head( + A2($elm$core$List$drop, 4, values))), + hoveredStrokeWidth: A2( + $elm$core$Maybe$withDefault, + '3', + $elm$core$List$head( + A2($elm$core$List$drop, 3, values))), + unHoveredFillColor: A2( + $elm$core$Maybe$withDefault, + 'white', + $elm$core$List$head( + A2($elm$core$List$drop, 5, values))), + unHoveredFillOpacity: A2( + $elm$core$Maybe$withDefault, + '0.0', + $elm$core$List$head( + A2($elm$core$List$drop, 6, values))), + unHoveredStrokeColor: A2( + $elm$core$Maybe$withDefault, + 'red', + $elm$core$List$head( + A2($elm$core$List$drop, 7, values))), + unHoveredStrokeOpacity: A2( + $elm$core$Maybe$withDefault, + '1.0', + $elm$core$List$head( + A2($elm$core$List$drop, 9, values))), + unHoveredStrokeWidth: A2( + $elm$core$Maybe$withDefault, + '3', + $elm$core$List$head( + A2($elm$core$List$drop, 8, values))) + }) : shapeStyle; + } else { + return shapeStyle; + } + }()); case 'ResetShowInput': return A3( $author$project$Manager$ModalManager$ShowInput, @@ -8780,7 +9448,7 @@ var $author$project$Manager$ModalManager$updateModal = F2( return modal; case 'ShowShape': return modal; - default: + case 'ShowInput': var iShape = modal.a; var ix = modal.b; var iy = modal.c; @@ -8794,6 +9462,8 @@ var $author$project$Manager$ModalManager$updateModal = F2( ix, iy, {x: 0, y: 0}); + default: + return modal; } default: switch (modal.$) { @@ -8803,7 +9473,7 @@ var $author$project$Manager$ModalManager$updateModal = F2( return modal; case 'ShowShape': return modal; - default: + case 'ShowInput': var iShape = modal.a; var ix = modal.b; var iy = modal.c; @@ -8816,167 +9486,74 @@ var $author$project$Manager$ModalManager$updateModal = F2( $author$project$Util$ShapeManager$getPointListFromPolygon(iShape))), '', ''); + default: + return modal; } } }); -var $elm$core$List$drop = F2( - function (n, list) { - drop: - while (true) { - if (n <= 0) { - return list; - } else { - if (!list.b) { - return list; - } else { - var x = list.a; - var xs = list.b; - var $temp$n = n - 1, - $temp$list = xs; - n = $temp$n; - list = $temp$list; - continue drop; - } - } - } - }); -var $elm$core$List$takeReverse = F3( - function (n, list, kept) { - takeReverse: +var $author$project$Util$ShapeManager$updateShapes = F2( + function (shapesMsg, shapeList) { + updateShapes: while (true) { - if (n <= 0) { - return kept; - } else { - if (!list.b) { - return kept; - } else { - var x = list.a; - var xs = list.b; - var $temp$n = n - 1, - $temp$list = xs, - $temp$kept = A2($elm$core$List$cons, x, kept); - n = $temp$n; - list = $temp$list; - kept = $temp$kept; - continue takeReverse; - } - } - } - }); -var $elm$core$List$takeTailRec = F2( - function (n, list) { - return $elm$core$List$reverse( - A3($elm$core$List$takeReverse, n, list, _List_Nil)); - }); -var $elm$core$List$takeFast = F3( - function (ctr, n, list) { - if (n <= 0) { - return _List_Nil; - } else { - var _v0 = _Utils_Tuple2(n, list); - _v0$1: - while (true) { - _v0$5: - while (true) { - if (!_v0.b.b) { - return list; - } else { - if (_v0.b.b.b) { - switch (_v0.a) { - case 1: - break _v0$1; - case 2: - var _v2 = _v0.b; - var x = _v2.a; - var _v3 = _v2.b; - var y = _v3.a; - return _List_fromArray( - [x, y]); - case 3: - if (_v0.b.b.b.b) { - var _v4 = _v0.b; - var x = _v4.a; - var _v5 = _v4.b; - var y = _v5.a; - var _v6 = _v5.b; - var z = _v6.a; - return _List_fromArray( - [x, y, z]); - } else { - break _v0$5; - } + switch (shapesMsg.$) { + case 'DeleteShape': + var id = shapesMsg.a; + return A2( + $elm$core$List$append, + A2($elm$core$List$take, id - 1, shapeList), + A2($elm$core$List$drop, id, shapeList)); + case 'AddShape': + var shape = shapesMsg.a; + return A2( + $elm$core$List$cons, + _Utils_Tuple2(shape, $author$project$Util$ShapeManager$defaultShapeStyle), + shapeList); + case 'SaveEditedShape': + var id = shapesMsg.a; + var shapeStyle = shapesMsg.b; + return A2( + $elm$core$List$append, + A2($elm$core$List$take, id - 1, shapeList), + A2( + $elm$core$List$cons, + _Utils_Tuple2( + A2( + $elm$core$Maybe$withDefault, + _Utils_Tuple2($author$project$Util$ShapeManager$Empty, shapeStyle), + $elm$core$List$head( + A2( + $elm$core$List$drop, + id - 1, + A2($elm$core$List$take, id, shapeList)))).a, + shapeStyle), + A2($elm$core$List$drop, id, shapeList))); + default: + var id = shapesMsg.a; + var shapeStyle = shapesMsg.b; + var inputType = shapesMsg.c; + var value = shapesMsg.d; + var $temp$shapesMsg = A2( + $author$project$Util$ShapeManager$SaveEditedShape, + id, + function () { + switch (inputType) { + case 'T': + return _Utils_update( + shapeStyle, + {title: value}); + case 'B': + return _Utils_update( + shapeStyle, + {body: value}); default: - if (_v0.b.b.b.b && _v0.b.b.b.b.b) { - var _v7 = _v0.b; - var x = _v7.a; - var _v8 = _v7.b; - var y = _v8.a; - var _v9 = _v8.b; - var z = _v9.a; - var _v10 = _v9.b; - var w = _v10.a; - var tl = _v10.b; - return (ctr > 1000) ? A2( - $elm$core$List$cons, - x, - A2( - $elm$core$List$cons, - y, - A2( - $elm$core$List$cons, - z, - A2( - $elm$core$List$cons, - w, - A2($elm$core$List$takeTailRec, n - 4, tl))))) : A2( - $elm$core$List$cons, - x, - A2( - $elm$core$List$cons, - y, - A2( - $elm$core$List$cons, - z, - A2( - $elm$core$List$cons, - w, - A3($elm$core$List$takeFast, ctr + 1, n - 4, tl))))); - } else { - break _v0$5; - } - } - } else { - if (_v0.a === 1) { - break _v0$1; - } else { - break _v0$5; + return shapeStyle; } - } - } - } - return list; + }()), + $temp$shapeList = shapeList; + shapesMsg = $temp$shapesMsg; + shapeList = $temp$shapeList; + continue updateShapes; } - var _v1 = _v0.b; - var x = _v1.a; - return _List_fromArray( - [x]); - } - }); -var $elm$core$List$take = F2( - function (n, list) { - return A3($elm$core$List$takeFast, 0, n, list); - }); -var $author$project$Util$ShapeManager$updateShapes = F2( - function (shapesMsg, shapeList) { - if (shapesMsg.$ === 'DeleteShape') { - var id = shapesMsg.a; - return A2( - $elm$core$List$append, - A2($elm$core$List$take, id - 1, shapeList), - A2($elm$core$List$drop, id, shapeList)); - } else { - var shape = shapesMsg.a; - return A2($elm$core$List$cons, shape, shapeList); } }); var $author$project$Manager$UpdateManager$updateModel = F2( @@ -9003,6 +9580,14 @@ var $author$project$Manager$UpdateManager$updateModel = F2( return A2($author$project$Manager$ModalManager$updateModal, modalMsg, modal); case 'OpenShowShape': return A2($author$project$Manager$ModalManager$updateModal, modalMsg, modal); + case 'OpenEditShape': + var id = modalMsg.a; + var ss = modalMsg.b; + var iT = modalMsg.c; + return A2( + $author$project$Manager$ModalManager$updateModal, + A4($author$project$Manager$ModalManager$OpenEditShape, id, ss, iT, value), + modal); case 'ResetShowInput': return A2($author$project$Manager$ModalManager$updateModal, modalMsg, modal); case 'Check': @@ -9020,42 +9605,70 @@ var $author$project$Manager$UpdateManager$updateModel = F2( }); case 'ManageShapes': var shapesMsg = msg.a; - if (shapesMsg.$ === 'DeleteShape') { - return _Utils_update( - model, - { - saved: A2($author$project$Util$ShapeManager$updateShapes, shapesMsg, model.saved) - }); - } else { - if (A2( - $author$project$Manager$ModalManager$eq_String_Modal, - 'ShowInput', - $author$project$Manager$StateManager$getModalFromState(model.state))) { - var $temp$msg = A2($author$project$TypeHolder$ManageModal, $author$project$Manager$ModalManager$ResetShowInput, ''), - $temp$model = _Utils_update( + var value = msg.b; + switch (shapesMsg.$) { + case 'DeleteShape': + return A2( + $author$project$Manager$ModalManager$eq_String_Modal, + 'ShowTable', + $author$project$Manager$StateManager$getModalFromState(model.state)) ? _Utils_update( model, { - saved: A2( - $author$project$Util$ShapeManager$updateShapes, - $author$project$Util$ShapeManager$AddShape( - $author$project$Manager$StateManager$getInputShapeFromState(model.state)), - model.saved) + saved: A2($author$project$Util$ShapeManager$updateShapes, shapesMsg, model.saved) + }) : _Utils_update( + model, + { + saved: A2($author$project$Util$ShapeManager$updateShapes, shapesMsg, model.saved), + state: $author$project$Manager$StateManager$Standby }); - msg = $temp$msg; - model = $temp$model; - continue updateModel; - } else { + case 'AddShape': + if (A2( + $author$project$Manager$ModalManager$eq_String_Modal, + 'ShowInput', + $author$project$Manager$StateManager$getModalFromState(model.state))) { + var $temp$msg = A2($author$project$TypeHolder$ManageModal, $author$project$Manager$ModalManager$ResetShowInput, ''), + $temp$model = _Utils_update( + model, + { + saved: A2( + $author$project$Util$ShapeManager$updateShapes, + $author$project$Util$ShapeManager$AddShape( + $author$project$Manager$StateManager$getInputShapeFromState(model.state)), + model.saved) + }); + msg = $temp$msg; + model = $temp$model; + continue updateModel; + } else { + return _Utils_update( + model, + { + saved: A2( + $author$project$Util$ShapeManager$updateShapes, + $author$project$Util$ShapeManager$AddShape( + $author$project$Manager$StateManager$getInputShapeFromState(model.state)), + model.saved), + state: $author$project$Manager$StateManager$Standby + }); + } + case 'SaveEditedShape': + return _Utils_update( + model, + { + saved: A2($author$project$Util$ShapeManager$updateShapes, shapesMsg, model.saved) + }); + default: + var id = shapesMsg.a; + var sS = shapesMsg.b; + var iT = shapesMsg.c; return _Utils_update( model, { saved: A2( $author$project$Util$ShapeManager$updateShapes, - $author$project$Util$ShapeManager$AddShape( - $author$project$Manager$StateManager$getInputShapeFromState(model.state)), - model.saved), - state: $author$project$Manager$StateManager$Standby + A4($author$project$Util$ShapeManager$SaveShapeStyle, id, sS, iT, value), + model.saved) }); - } } case 'SvgShapeHover': var id = msg.a; @@ -9121,12 +9734,13 @@ var $author$project$Manager$UpdateManager$updateModel = F2( model, { saved: A2( - $elm$core$List$cons, - A3( - $author$project$Util$ShapeManager$Circle, - x, - y, - A3($author$project$Util$Util$abstand, x, y, mPos)), + $author$project$Util$ShapeManager$updateShapes, + $author$project$Util$ShapeManager$AddShape( + A3( + $author$project$Util$ShapeManager$Circle, + x, + y, + A3($author$project$Util$Util$abstand, x, y, mPos))), model.saved), state: $author$project$Manager$StateManager$Standby }); @@ -9167,8 +9781,9 @@ var $author$project$Manager$UpdateManager$updateModel = F2( model, { saved: A2( - $elm$core$List$cons, - A4($author$project$Util$ShapeManager$Rectangle, coords.x, coords.y, coords.w, coords.h), + $author$project$Util$ShapeManager$updateShapes, + $author$project$Util$ShapeManager$AddShape( + A4($author$project$Util$ShapeManager$Rectangle, coords.x, coords.y, coords.w, coords.h)), model.saved), state: $author$project$Manager$StateManager$Standby }); @@ -9193,25 +9808,26 @@ var $author$project$Manager$UpdateManager$updateModel = F2( mPos) }); } else { - var coords = $author$project$Util$Util$manageRectCoords( + var coords = $author$project$Util$Util$manageEllipseCoords( { - h: A2( - $author$project$Util$Util$abstand1D, - mPos.y, - $author$project$Util$Util$stringToInt(b)), - w: A2( + cx: a, + cy: b, + rx: A2( $author$project$Util$Util$abstand1D, mPos.x, $author$project$Util$Util$stringToInt(a)), - x: a, - y: b + ry: A2( + $author$project$Util$Util$abstand1D, + mPos.y, + $author$project$Util$Util$stringToInt(b)) }); return _Utils_update( model, { saved: A2( - $elm$core$List$cons, - A4($author$project$Util$ShapeManager$Ellipse, coords.x, coords.y, coords.w, coords.h), + $author$project$Util$ShapeManager$updateShapes, + $author$project$Util$ShapeManager$AddShape( + A4($author$project$Util$ShapeManager$Ellipse, coords.cx, coords.cy, coords.rx, coords.ry)), model.saved), state: $author$project$Manager$StateManager$Standby }); @@ -9256,7 +9872,8 @@ var $author$project$Manager$UpdateManager$updateModel = F2( return _Utils_update( model, { - saved: $author$project$Util$ShapeManager$shapesDecoder(s), + saved: $author$project$Util$ShapeManager$shapeListToShape_ShapeStyleList( + $author$project$Util$ShapeManager$shapesDecoder(s)), shapesLoadResult: result }); } @@ -9273,7 +9890,7 @@ var $author$project$Manager$UpdateManager$updateModel = F2( return _Utils_update( model, { - saved: shapes, + saved: $author$project$Util$ShapeManager$shapeListToShape_ShapeStyleList(shapes), shapesLoadResult: $elm$core$Result$Ok('shapes') }); } else { diff --git a/src/Manager/ModalManager.elm b/src/Manager/ModalManager.elm index bb543bf..c23bc54 100644 --- a/src/Manager/ModalManager.elm +++ b/src/Manager/ModalManager.elm @@ -7,14 +7,16 @@ type Modal = NoModal | ShowTable | ShowInput Shape String String - | ShowShape Int + | ShowShape Int Int + | EditShape Int ShapeStyle type ModalMsg = CloseModal -- show Modal | OpenShowTable | OpenShowInput - | OpenShowShape Int + | OpenShowShape Int Int + | OpenEditShape Int ShapeStyle String String -- for input / delete Shapes | ResetShowInput | Check String @@ -32,9 +34,30 @@ updateModal msg modal = OpenShowInput -> if (eq_String_Modal "ShowInput" modal) then NoModal else ShowInput Empty "" "" - OpenShowShape id -> if (id <= 0) + OpenShowShape id edit -> if (id <= 0) + then NoModal + else ShowShape id edit + OpenEditShape id shapeStyle inputType value-> + if (id <= 0) then NoModal - else ShowShape id + else EditShape id (case inputType of + "TA" -> let values = String.split "\n" value + in if List.length values==10 + then { shapeStyle + | hoveredFillColor = Maybe.withDefault "white" (List.head values) + , hoveredFillOpacity = Maybe.withDefault "0.5" (List.head (List.drop 1 values)) + , hoveredStrokeColor = Maybe.withDefault "red" (List.head (List.drop 2 values)) + , hoveredStrokeWidth = Maybe.withDefault "3" (List.head (List.drop 3 values)) + , hoveredStrokeOpacity = Maybe.withDefault "1.0" (List.head (List.drop 4 values)) + , unHoveredFillColor = Maybe.withDefault "white" (List.head (List.drop 5 values)) + , unHoveredFillOpacity = Maybe.withDefault "0.0" (List.head (List.drop 6 values)) + , unHoveredStrokeColor = Maybe.withDefault "red" (List.head (List.drop 7 values)) + , unHoveredStrokeWidth = Maybe.withDefault "3" (List.head (List.drop 8 values)) + , unHoveredStrokeOpacity = Maybe.withDefault "1.0" (List.head (List.drop 9 values)) + } + else shapeStyle + _ -> shapeStyle + ) ResetShowInput -> ShowInput (deleteCoordsFromShape (getInputShapeFromModal modal) @@ -48,13 +71,15 @@ updateModal msg modal = case modal of NoModal -> modal -- ERROR ShowTable -> modal -- ERROR - ShowShape _ -> modal -- ERROR + ShowShape _ _ -> modal -- ERROR ShowInput iShape ix iy -> updateInput inputType value modal "ShowInput" iShape ix iy {x = 0, y = 0} + EditShape _ _ -> modal -- ERROR InputPoint -> case modal of NoModal -> modal -- ERROR ShowTable -> modal -- ERROR - ShowShape _ -> modal -- ERROR + ShowShape _ _ -> modal -- ERROR ShowInput iShape ix iy -> ShowInput (Polygon ((ix,iy)::(getPointListFromPolygon iShape))) "" "" + EditShape _ _ -> modal -- ERROR updateInput : Char -> String -> Modal -> String -> Shape -> String -> String -> MousePosition -> Modal updateInput inputType value modal modalType iShape ix iy mouse = case inputType of @@ -62,25 +87,25 @@ updateInput inputType value modal modalType iShape ix iy mouse = Empty -> modal -- ERROR Circle _ b c -> modalInputConstruktor modalType (Circle value b c ) ix iy mouse Rectangle _ b c d -> modalInputConstruktor modalType (Rectangle value b c d) ix iy mouse - Ellipse _ b c d -> modalInputConstruktor modalType (Ellipse value b c d) ix iy mouse + Ellipse _ b c d -> modalInputConstruktor modalType (Ellipse value b c d) ix iy mouse Polygon _ -> modalInputConstruktor modalType iShape value iy mouse '2' -> case iShape of Empty -> modal -- ERROR Circle a _ c -> modalInputConstruktor modalType (Circle a value c ) ix iy mouse Rectangle a _ c d -> modalInputConstruktor modalType (Rectangle a value c d) ix iy mouse - Ellipse a _ c d -> modalInputConstruktor modalType (Ellipse a value c d) ix iy mouse + Ellipse a _ c d -> modalInputConstruktor modalType (Ellipse a value c d) ix iy mouse Polygon _ -> modalInputConstruktor modalType iShape ix value mouse '3' -> case iShape of Empty -> modal -- ERROR Circle a b _ -> modalInputConstruktor modalType (Circle a b value ) ix iy mouse Rectangle a b _ d -> modalInputConstruktor modalType (Rectangle a b value d) ix iy mouse - Ellipse a b _ d -> modalInputConstruktor modalType (Ellipse a b value d) ix iy mouse + Ellipse a b _ d -> modalInputConstruktor modalType (Ellipse a b value d) ix iy mouse Polygon _ -> modal -- ERROR '4' -> case iShape of Empty -> modal -- ERROR Circle _ _ _ -> modal -- ERROR Rectangle a b c _ -> modalInputConstruktor modalType (Rectangle a b c value) ix iy mouse - Ellipse a b c _ -> modalInputConstruktor modalType (Ellipse a b c value) ix iy mouse + Ellipse a b c _ -> modalInputConstruktor modalType (Ellipse a b c value) ix iy mouse Polygon _ -> modal -- ERROR _ -> modal -- ERROR -- Modal Construktors @@ -99,7 +124,8 @@ getInputShapeFromModal modal = NoModal -> Empty ShowTable -> Empty ShowInput shape _ _ -> shape - ShowShape _ -> Empty + ShowShape _ _ -> Empty + EditShape _ _ -> Empty -- Transform Modal to other Types modalNameToString : Modal -> String modalNameToString modal = @@ -107,4 +133,5 @@ modalNameToString modal = NoModal -> "NoModal" ShowTable -> "ShowTable" ShowInput _ _ _ -> "ShowInput" - ShowShape _ -> "ShowShape" \ No newline at end of file + ShowShape _ _ -> "ShowShape" + EditShape _ _ -> "EditShape" \ No newline at end of file diff --git a/src/Manager/UpdateManager.elm b/src/Manager/UpdateManager.elm index 382c011..0b5c182 100644 --- a/src/Manager/UpdateManager.elm +++ b/src/Manager/UpdateManager.elm @@ -26,26 +26,33 @@ updateModel msg model = let modal = getModalFromState model.state in { model | state = manageState (ActiveModal (case modalMsg of - CloseModal -> updateModal modalMsg modal - OpenShowInput -> updateModal modalMsg modal - OpenShowTable -> updateModal modalMsg modal - OpenShowShape _ -> updateModal modalMsg modal - ResetShowInput -> updateModal modalMsg modal - Check _ -> updateModal modalMsg modal - Input inputType _ -> updateModal (Input inputType value) modal - InputPoint -> updateModal modalMsg modal + CloseModal -> updateModal modalMsg modal + OpenShowInput -> updateModal modalMsg modal + OpenShowTable -> updateModal modalMsg modal + OpenShowShape _ _ -> updateModal modalMsg modal + OpenEditShape id ss iT _ -> updateModal (OpenEditShape id ss iT value) modal + ResetShowInput -> updateModal modalMsg modal + Check _ -> updateModal modalMsg modal + Input inputType _ -> updateModal (Input inputType value) modal + InputPoint -> updateModal modalMsg modal ) ) } - ManageShapes shapesMsg -> + ManageShapes shapesMsg value-> case shapesMsg of - DeleteShape _ -> { model | saved = updateShapes shapesMsg model.saved} + DeleteShape _ -> if (eq_String_Modal "ShowTable" (getModalFromState model.state)) + then { model | saved = updateShapes shapesMsg model.saved} + else { model | saved = updateShapes shapesMsg model.saved + , state = Standby + } AddShape _ -> if (eq_String_Modal "ShowInput" (getModalFromState model.state)) then updateModel (ManageModal ResetShowInput "") { model | saved = updateShapes (AddShape (getInputShapeFromState model.state)) model.saved} else { model | saved = updateShapes (AddShape (getInputShapeFromState model.state)) model.saved , state = Standby } + SaveEditedShape _ _ -> { model | saved = updateShapes shapesMsg model.saved} + SaveShapeStyle id sS iT _ -> { model | saved = updateShapes (SaveShapeStyle id sS iT value) model.saved} SvgShapeHover id -> { model | svgShapeHover = id} OpenDrawShape shape -> { model | state = DrawShape shape {x = 0, y = 0} } UpdateMousePos mouse -> case model.state of @@ -60,7 +67,7 @@ updateModel msg model = Circle x y r -> if x=="" then { model | state = DrawShape (Circle (String.fromInt mPos.x) (String.fromInt mPos.y) r ) mPos } - else { model | saved = (Circle x y (abstand x y mPos))::model.saved + else { model | saved = updateShapes (AddShape (Circle x y (abstand x y mPos))) model.saved , state = Standby } Rectangle a b w h -> @@ -75,7 +82,7 @@ updateModel msg model = ,w= (abstand1D mPos.x (stringToInt a)) ,h= (abstand1D mPos.y (stringToInt b)) } - in { model | saved = (Rectangle coords.x coords.y coords.w coords.h)::model.saved + in { model | saved = updateShapes (AddShape (Rectangle coords.x coords.y coords.w coords.h)) model.saved , state = Standby } Ellipse a b w h -> @@ -84,13 +91,13 @@ updateModel msg model = (Ellipse (String.fromInt mPos.x) (String.fromInt mPos.y) w h) mPos } - else let coords = manageRectCoords - {x= a - ,y= b - ,w= (abstand1D mPos.x (stringToInt a)) - ,h= (abstand1D mPos.y (stringToInt b)) + else let coords = manageEllipseCoords + {cx= a + ,cy= b + ,rx= (abstand1D mPos.x (stringToInt a)) + ,ry= (abstand1D mPos.y (stringToInt b)) } - in { model | saved = (Ellipse coords.x coords.y coords.w coords.h)::model.saved + in { model | saved = updateShapes (AddShape (Ellipse coords.cx coords.cy coords.rx coords.ry)) model.saved , state = Standby } Polygon pList -> { model | state = DrawShape @@ -108,12 +115,12 @@ updateModel msg model = Ok "Fenster" -> model Ok "T%C3%BCren" -> model --%C3%BC = ü Ok s -> { model | shapesLoadResult = result - , saved = shapesDecoder s + , saved = shapeListToShape_ShapeStyleList (shapesDecoder s) } Err e -> { model | shapesLoadResult = result } ShapesLoaded result -> case result of - Ok shapes-> { model | saved = shapes, shapesLoadResult = Ok "shapes"} + Ok shapes-> { model | saved = shapeListToShape_ShapeStyleList shapes, shapesLoadResult = Ok "shapes"} Err e -> { model | saved = [] , shapesLoadResult = (Err e )} LinkClicked urlRequest -> model UrlChanged url -> { model | url = url} @@ -121,7 +128,7 @@ updateCmdMsg : Msg -> Model -> Cmd Msg updateCmdMsg msg model = case msg of ManageModal _ _ -> Cmd.none - ManageShapes _ -> Cmd.none + ManageShapes _ _ -> Cmd.none SvgShapeHover _ -> Cmd.none UpdateMousePos _ -> Cmd.none InputDrawShape -> Cmd.none diff --git a/src/Manager/ViewManager.elm b/src/Manager/ViewManager.elm index d567881..b7d35b8 100644 --- a/src/Manager/ViewManager.elm +++ b/src/Manager/ViewManager.elm @@ -1,12 +1,14 @@ module Manager.ViewManager exposing (view) -- Html import Html exposing (Html, Attribute, div, text, node, button, a, h1, h2, label, figure, input, td, th, tr, table) -import Html.Attributes exposing (class, style, href, rel, id, title, value) +import Html.Attributes exposing (class, style, href, rel, id, title, value, src) import Html.Events exposing (onClick, onInput) -- Svg import Svg exposing (Svg,svg, image,rect,ellipse,circle,polygon,g) import Svg.Attributes exposing (width,height, viewBox, version, xlinkHref, x, y, cx, cy,rx,ry, r) import Svg.Events +-- Url +import Url -- Own import TypeHolder exposing (Model,Msg(..)) import Manager.StateManager exposing (..) @@ -37,9 +39,18 @@ view model = ] , case (getModalFromState model.state) of NoModal -> [] - ShowInput iShape ix iy -> [viewNewShapeInputModal iShape ix iy] - ShowTable -> [viewTableModal model.saved ] - ShowShape id -> [viewShapeModal id ] + ShowInput iShape ix iy -> [viewNewShapeInputModal iShape ix iy ] + ShowTable -> [viewTableModal model.saved ] + ShowShape id edit -> [viewShapeModal id edit + ( model.saved + |> List.take (id ) + |> List.drop (id-1) + |> List.head + |> Maybe.withDefault (Empty,defaultShapeStyle) + |> Tuple.second + ) + ] + EditShape id shapeStyle-> [viewEditShapeModal id shapeStyle] ] ) -- Parts of the VIEW @@ -78,7 +89,7 @@ viewHeader_Buttons state = in if (eq_String_Shape "Polygon" iShape) then viewDropDownMenue "Polygon wird gezeichnet" True "angle-down" [] [ a [class "dropdown-item" - , onClick (ManageShapes (AddShape Empty)) + , onClick (ManageShapes (AddShape Empty) "") , href "" ] [text "Speichern"] , a [class "dropdown-item" @@ -100,10 +111,10 @@ viewHeader_Buttons state = , onClick (OpenDrawShape (Rectangle "" "" "" "")) , href "" ] [text "Rechteck"] - , a [class "dropdown-item" - , onClick (OpenDrawShape (Ellipse "" "" "" "")) - , href "" - ] [text "Ellipse"] + , a [class "dropdown-item" + , onClick (OpenDrawShape (Ellipse "" "" "" "")) + , href "" + ] [text "Ellipse"] , a [class "dropdown-item" , onClick (OpenDrawShape (Polygon [])) , href "" @@ -118,7 +129,7 @@ viewImage model = [ svg [ width "100%", viewBox "0 0 800 600", version "1.1"] ( List.concat [[image [ width "800", height "600" - , xlinkHref "http://www.informatik.uni-halle.de/im/1285058520_1381_00_800.jpg" + , xlinkHref (Url.toString model.pictureUrl) ] [] ] , viewSvgShapes model.saved model.svgShapeHover 1 @@ -137,16 +148,16 @@ viewImage model = , cy (String.fromInt mPos.y) , rx "10", ry "10"] [] else let coords = manageEllipseCoords - {x= a - ,y= b - ,w= (abstand1D mPos.x (stringToInt a)) - ,h= (abstand1D mPos.y (stringToInt b)) + {cx= a + ,cy= b + ,rx= (abstand1D mPos.x (stringToInt a)) + ,ry= (abstand1D mPos.y (stringToInt b)) } - in ellipse [ cx coords.x - , cy coords.y - , rx coords.w - , ry coords.h - ] [] + in ellipse [ cx coords.cx + , cy coords.cy + , rx coords.rx + , ry coords.ry + ] [] Rectangle a b w h -> if a=="" then rect [ x (String.fromInt mPos.x) , y (String.fromInt mPos.y) @@ -292,11 +303,11 @@ viewNewShapeInputModal iShape ix iy = ) ) , modalFooter [ button [ class "button is-success" - , onClick (ManageShapes (AddShape Empty)) + , onClick (ManageShapes (AddShape Empty) "") ] [text "Form hinzufügen"] - ] 27 + ] 27.0 ] -viewTableModal : List (Shape) -> Html Msg +viewTableModal : List (Shape, ShapeStyle) -> Html Msg viewTableModal modelSaved = modalCard [ modalHeader "Tabelle mit Formen" @@ -305,10 +316,11 @@ viewTableModal modelSaved = then [ div [] [text "Es sind keine Formen vorhanden!"] ] else [ table [class "table"] ( List.append [ tr [] - [ th [] [text "ID"] + [ th [] [text "Name/ID"] , th [] [text "Form"] , th [] [text "Koordinaten"] , th [] [text ""] + , th [] [text ""] ] ] ( writeShapeToTable modelSaved 1) @@ -317,14 +329,100 @@ viewTableModal modelSaved = ) , modalFooter [] 0 ] -viewShapeModal : Int -> Html Msg -viewShapeModal id = +viewShapeModal : Int -> Int -> ShapeStyle -> Html Msg +viewShapeModal id edit shapeStyle = + if id <= 0 then div [] [] -- ERROR + else modalCard [ modalStrongHeader [Html.Events.onDoubleClick (ManageModal (OpenShowShape id 1) "") + ,Html.Events.onMouseLeave (ManageModal (OpenShowShape id 0) "") + ] [ + if edit==1 + then label [] [ input [ class "input" + , value shapeStyle.title + , onInput (ManageShapes (SaveShapeStyle id shapeStyle "T" "")) + ] [] + ] + else text (if shapeStyle.title=="default" + then ("Form "++String.fromInt id) + else shapeStyle.title + ) + ] + , modalCardStrongBody [Html.Events.onDoubleClick (ManageModal (OpenShowShape id 2) "") + ,Html.Events.onMouseLeave (ManageModal (OpenShowShape id 0) "") + ] [ + if edit==2 + then label [] [ input [ class "input" + , value shapeStyle.body + , onInput (ManageShapes (SaveShapeStyle id shapeStyle "B" "")) + ] [] + ] + else if shapeStyle.body=="default" + then text ("Form "++String.fromInt id++" wurde gefunden!") + else case Url.fromString shapeStyle.body of + Just url -> Html.iframe [ src shapeStyle.body + , style "width" "100%" + , style "height" "100%"] [] + Nothing -> text shapeStyle.body + ] + , modalFooter [ shapeEditButton id shapeStyle "6" + , shapeDeleteButton id "6" + ] 49.1 + ] +viewEditShapeModal : Int -> ShapeStyle -> Html Msg +viewEditShapeModal id shapeStyle = if id <= 0 then div [] [] -- ERROR else modalCard - [ modalHeader ("Form "++String.fromInt id) - , Html.section [ class "modal-card-body"] - [ text ("Form "++String.fromInt id++" wurde gefunden!")] - , modalFooter [] 0 + [ modalHeader ("Form "++(if shapeStyle.title=="default" + then String.fromInt id + else shapeStyle.title)++" bearbeiten") + , modalCardBody [ div [class "control"] + [ table [class "table"] + [ tr [] [ th [] [text "Optionen"] + , th [] [text "Werte"] + ] + , tr [] [ td [] [ Html.textarea [class "textarea has-fixed-size is-medium" + , Html.Attributes.rows 10 + , Html.Attributes.cols 20 + , Html.Attributes.readonly True + ] [ + text "hoveredFillColor \n" + , text "hoveredFillOpacity \n" + , text "hoveredStrokeColor \n" + , text "hoveredStrokeWidth \n" + , text "hoveredStrokeOpacity\n" + , text "unHoveredFillColor \n" + , text "unHoveredFillOpacity\n" + , text "unHoveredStrokeColor\n" + , text "unHoveredStrokeWidth\n" + , text "unHoveredStrokeOpacity" + ] + ] + , td [] [ Html.textarea [ class "textarea has-fixed-size is-medium" + , Html.Attributes.rows 10 + , Html.Attributes.cols 10 + , onInput (ManageModal (OpenEditShape id shapeStyle "TA" "")) + ] [ + text (shapeStyle.hoveredFillColor ++"\n") + , text (shapeStyle.hoveredFillOpacity ++"\n") + , text (shapeStyle.hoveredStrokeColor ++"\n") + , text (shapeStyle.hoveredStrokeWidth ++"\n") + , text (shapeStyle.hoveredStrokeOpacity++"\n") + , text (shapeStyle.unHoveredFillColor ++"\n") + , text (shapeStyle.unHoveredFillOpacity++"\n") + , text (shapeStyle.unHoveredStrokeColor++"\n") + , text (shapeStyle.unHoveredStrokeWidth++"\n") + , text shapeStyle.unHoveredStrokeOpacity + ] + ] + ] + ] + ] + ] + , modalFooter [ button [ class "button is-success" + , onClick (ManageShapes (SaveEditedShape id shapeStyle) "") + ] + [ text "Speichern"] + , shapeDeleteButton id "6" + ] 41.1 ] -- Helping Methods for the VIEW viewDropDownMenue : String -> Bool -> String -> List(Attribute Msg) -> List(Svg Msg) -> Html Msg @@ -349,43 +447,67 @@ viewDropDownMenue header isGreen iconType attributes dropDownItems = else div [ class "dropdown-menu role=menu"] [ div [ class "dropdown-content"] dropDownItems ] ] -viewSvgShapes : List Shape -> Int -> Int -> List (Svg Msg) +viewSvgShapes : List (Shape, ShapeStyle) -> Int -> Int -> List (Svg Msg) viewSvgShapes shapes activeShape id = case shapes of [] -> [] - x::xs -> ( case x of - Empty -> rect [] [] - Circle a b c -> circle ([cx a, cy b, r c ] - ++svgShapeStyle activeShape id) [] - Rectangle a b c d -> rect ([Svg.Attributes.x a, y b, width c, height d ] - ++svgShapeStyle activeShape id) [] - Ellipse a b c d -> ellipse ([Svg.Attributes.cx a, cy b, rx c, ry d ] - ++svgShapeStyle activeShape id) [] - Polygon pointList -> polygon([Svg.Attributes.points (shapeCoordsToHtmlCoords x)] - ++svgShapeStyle activeShape id) [] + x::xs -> (let f = Tuple.first x + s = Tuple.second x + in + case f of + Empty -> rect [] [] + Circle a b c -> circle ([cx a, cy b, r c ] + ++svgShapeStyle s activeShape id) [] + Rectangle a b c d -> rect ([Svg.Attributes.x a, y b, width c, height d ] + ++svgShapeStyle s activeShape id) [] + Ellipse a b c d -> ellipse([Svg.Attributes.cx a, cy b, rx c, ry d ] + ++svgShapeStyle s activeShape id) [] + Polygon pointList -> polygon([Svg.Attributes.points (shapeCoordsToHtmlCoords f)] + ++svgShapeStyle s activeShape id) [] )::viewSvgShapes xs activeShape (id+1) -svgShapeStyle : Int -> Int -> List( Svg.Attribute Msg) -svgShapeStyle activeShape id = - [ Svg.Attributes.fill "white" - , Svg.Attributes.fillOpacity (if activeShape==id then "0.5" else "0.0") - , Svg.Attributes.stroke "red" - , Svg.Attributes.strokeWidth "3" - , Svg.Events.onMouseOver (SvgShapeHover id) - , Svg.Events.onMouseOut (SvgShapeHover 0) - , Svg.Events.onClick (ManageModal (OpenShowShape id) "") +svgShapeStyle : ShapeStyle -> Int -> Int -> List(Svg.Attribute Msg) +svgShapeStyle shapeStyle activeShape id = + List.concat + [if activeShape==id + then [ Svg.Attributes.fill shapeStyle.hoveredFillColor + , Svg.Attributes.fillOpacity shapeStyle.hoveredFillOpacity + , Svg.Attributes.stroke shapeStyle.hoveredStrokeColor + , Svg.Attributes.strokeWidth shapeStyle.hoveredStrokeWidth + , Svg.Attributes.strokeOpacity shapeStyle.hoveredStrokeOpacity + ] + else [ Svg.Attributes.fill shapeStyle.unHoveredFillColor + , Svg.Attributes.fillOpacity shapeStyle.unHoveredFillOpacity + , Svg.Attributes.stroke shapeStyle.unHoveredStrokeColor + , Svg.Attributes.strokeWidth shapeStyle.unHoveredStrokeWidth + , Svg.Attributes.strokeOpacity shapeStyle.unHoveredStrokeOpacity + ] + ,[ Svg.Events.onMouseOver (SvgShapeHover id) + , Svg.Events.onMouseOut (SvgShapeHover 0) + , Svg.Events.onClick (ManageModal (OpenShowShape id 0) "") + ] ] -writeShapeToTable : List ( Shape ) -> Int -> List ( Html Msg ) -writeShapeToTable shapeList id = - case shapeList of +writeShapeToTable : List (Shape, ShapeStyle) -> Int -> List (Html Msg) +writeShapeToTable shapes id = + case shapes of [] -> [] - x::xs -> tr [Html.Attributes.id ("Shape"++String.fromInt id)] - [ td [] [text ("Form"++String.fromInt id)] - , td [] [text (shapeNameStringToGerman(shapeNameToString x))] - , td [] [text (shapeCoordsToString x)] - , td [] [button [ class "button is-danger is-size-7" - , onClick (ManageShapes (DeleteShape id))] [ text "Form löschen" ] ] - ] - :: (writeShapeToTable xs (id+1)) + x::xs -> let f = Tuple.first x + s = Tuple.second x + in tr [Html.Attributes.id ("Shape"++String.fromInt id)] + [ td [] [text (if s.title=="default"then ("Form"++String.fromInt id) else s.title)] + , td [] [text (shapeNameStringToGerman(shapeNameToString f))] + , td [] [text (shapeCoordsToString f)] + , td [] [shapeDeleteButton id "7"] + , td [] [shapeEditButton id s "7"] + ] + :: (writeShapeToTable xs (id+1)) +-- Small view objects +shapeDeleteButton : Int -> String -> Html Msg +shapeDeleteButton id size = button [ class ("button is-danger is-size-"++size) + , onClick (ManageShapes (DeleteShape id) "")] [ text "Form löschen" ] +shapeEditButton : Int -> ShapeStyle -> String -> Html Msg +shapeEditButton id shapeStyle size = button [ class ("button is-size-"++size) + , onClick (ManageModal (OpenEditShape id shapeStyle "" "") "")] + [ text "Form bearbeiten"] -- Modal view-Elements modalCard : List (Html Msg) -> Html Msg modalCard modalParts = @@ -394,19 +516,24 @@ modalCard modalParts = , div [class "modal-card"] modalParts ] modalHeader : String -> Html Msg -modalHeader title = Html.header [class "modal-card-head"] - [ Html.p [class "modal-card-title" ] [text title] - , button [class "delete aria-label=close", onClick (ManageModal CloseModal "")] [] - ] +modalHeader title = modalStrongHeader [] [text title] modalCardBody : List (Html Msg) -> Html Msg -modalCardBody bodyElements = Html.section [class "modal-card-body"] bodyElements -modalFooter : List (Html Msg) -> Int-> Html Msg +modalCardBody bodyElements = modalCardStrongBody [] bodyElements +modalFooter : List (Html Msg) -> Float -> Html Msg modalFooter footElements footElementsWidth = Html.footer [class "modal-card-foot"] (List.append footElements [ button [ class "button" - , style "margin-left" ((String.fromInt (83-footElementsWidth))++"%") + , style "margin-left" ((String.fromFloat (83.0-footElementsWidth))++"%") , onClick (ManageModal CloseModal "") ][text "Schließen"] ] - ) \ No newline at end of file + ) +modalStrongHeader : List (Attribute Msg) -> List (Html Msg) -> Html Msg +modalStrongHeader attributes children = + Html.header [class "modal-card-head"] + [ Html.p ([class "modal-card-title"]++attributes) children + , button [class "delete aria-label=close", onClick (ManageModal CloseModal "")] [] + ] +modalCardStrongBody : List (Attribute Msg) -> List (Html Msg) -> Html Msg +modalCardStrongBody attributes children = Html.section ([class "modal-card-body"]++attributes) children \ No newline at end of file diff --git a/src/ShapePicture_Editor.elm b/src/ShapePicture_Editor.elm index 380dc54..3ccbc43 100644 --- a/src/ShapePicture_Editor.elm +++ b/src/ShapePicture_Editor.elm @@ -18,7 +18,6 @@ main = Browser.application , onUrlChange = UrlChanged , onUrlRequest = LinkClicked } - -- INIT init : () -> Url.Url -> Nav.Key-> (Model, Cmd Msg) init _ url key = @@ -27,6 +26,14 @@ init _ url key = [] 0 (Ok " Init") + ( Url.Url + Url.Http + "www.informatik.uni-halle.de" + Nothing + "/im/1285058520_1381_00_800.jpg" + Nothing + Nothing + ) url key , Cmd.none diff --git a/src/TypeHolder.elm b/src/TypeHolder.elm index 04c5faf..6faa9ac 100644 --- a/src/TypeHolder.elm +++ b/src/TypeHolder.elm @@ -9,21 +9,22 @@ import Url -- Own import Manager.StateManager exposing (State) import Manager.ModalManager exposing (Modal, ModalMsg) -import Util.ShapeManager exposing (Shape, ShapesMsg) +import Util.ShapeManager exposing (Shape, ShapeStyle, ShapesMsg) import Util.Util exposing (MousePosition) type alias Model = { state : State - , saved : List (Shape) + , saved : List (Shape, ShapeStyle) , svgShapeHover : Int , shapesLoadResult : (Result Http.Error String) + , pictureUrl : Url.Url , url : Url.Url , key : Nav.Key } type Msg -- Manage Objects = ManageModal ModalMsg String - | ManageShapes ShapesMsg + | ManageShapes ShapesMsg String -- svg | SvgShapeHover Int -- for drawing shapes @@ -35,5 +36,4 @@ type Msg | ShapesLoaded (Result Http.Error (List Shape)) -- Url | LinkClicked Browser.UrlRequest - | UrlChanged Url.Url - + | UrlChanged Url.Url \ No newline at end of file diff --git a/src/Util/ShapeManager.elm b/src/Util/ShapeManager.elm index 9e1e870..11c20c6 100644 --- a/src/Util/ShapeManager.elm +++ b/src/Util/ShapeManager.elm @@ -9,18 +9,50 @@ type Shape | Ellipse String String String String | Polygon (List ( String, String ) ) +type alias ShapeStyle = + { hoveredFillColor : String + , hoveredFillOpacity : String + , hoveredStrokeColor : String + , hoveredStrokeWidth : String + , hoveredStrokeOpacity : String + , unHoveredFillColor : String + , unHoveredFillOpacity : String + , unHoveredStrokeColor : String + , unHoveredStrokeWidth : String + , unHoveredStrokeOpacity : String + , title : String + , body : String + } + type ShapesMsg = DeleteShape Int | AddShape Shape + | SaveEditedShape Int ShapeStyle + | SaveShapeStyle Int ShapeStyle String String -- Update -updateShapes : ShapesMsg -> List Shape -> List Shape +updateShapes : ShapesMsg -> List (Shape, ShapeStyle) -> List (Shape, ShapeStyle) updateShapes shapesMsg shapeList = case shapesMsg of DeleteShape id -> List.append (List.take (id-1) shapeList) (List.drop (id) shapeList) - AddShape shape -> shape::shapeList - + AddShape shape -> (shape,defaultShapeStyle)::shapeList + SaveEditedShape id shapeStyle -> List.append (List.take (id-1) shapeList) + ((shapeList + |> List.take (id ) + |> List.drop (id-1) + |> List.head + |> Maybe.withDefault (Empty,shapeStyle) + |> Tuple.first + ,shapeStyle + )::(List.drop (id) shapeList) + ) + SaveShapeStyle id shapeStyle inputType value -> updateShapes (SaveEditedShape id (case inputType of + "T" -> { shapeStyle | title = value } + "B" -> { shapeStyle | body = value } + _ -> shapeStyle -- ERROR + ) + ) shapeList -- Shape Construktors shapeDefaultConstruktor : String -> Shape shapeDefaultConstruktor shape = @@ -64,6 +96,11 @@ shapesDecoder s = ] else [] ] +-- ShapeStyle Constructors +defaultShapeStyle : ShapeStyle +defaultShapeStyle = ShapeStyle "white" "0.5" "red" "3" "1.0" + "white" "0.0" "red" "3" "1.0" + "default" "default" -- Operations on Shapes eq_String_Shape : String -> Shape -> Bool eq_String_Shape string shape = string==(shapeNameToString shape) @@ -82,16 +119,18 @@ getPointListFromPolygon shape = Empty -> [] Circle _ _ _ -> [] Rectangle _ _ _ _ -> [] - Ellipse _ _ _ _ -> [] + Ellipse _ _ _ _ -> [] Polygon pointList -> pointList -- Transform Shape to other Types +shapeListToShape_ShapeStyleList : List Shape -> List (Shape, ShapeStyle) +shapeListToShape_ShapeStyleList shapes = List.map2 Tuple.pair shapes (List.repeat (List.length shapes) defaultShapeStyle) shapeNameToString : Shape -> String shapeNameToString shape = case shape of Empty -> "" Circle _ _ _ -> "Circle" Rectangle _ _ _ _ -> "Rectangle" - Ellipse _ _ _ _ -> "Ellipse" + Ellipse _ _ _ _ -> "Ellipse" Polygon _ -> "Polygon" shapeNameStringToGerman : String -> String shapeNameStringToGerman shape = diff --git a/src/Util/Util.elm b/src/Util/Util.elm index 747d8b1..cc39b4d 100644 --- a/src/Util/Util.elm +++ b/src/Util/Util.elm @@ -47,24 +47,22 @@ manageRectCoords coords = then {x=String.fromInt (x+w),y=String.fromInt y ,w=String.fromInt -w,h=String.fromInt h} else {x=String.fromInt (x+w),y=String.fromInt (y+h),w=String.fromInt -w,h=String.fromInt -h} type alias EllipseCoords = - { x : String - , y : String - , w : String - , h : String + { cx : String + , cy : String + , rx : String + , ry : String } manageEllipseCoords : EllipseCoords -> EllipseCoords manageEllipseCoords coords = - let x = stringToInt coords.x - y = stringToInt coords.y - w = stringToInt coords.w - h = stringToInt coords.h - in if w>0 - then if h>0 + let rx = stringToInt coords.rx + ry = stringToInt coords.ry + in if rx>0 + then if ry>0 then coords - else {x=String.fromInt x,y=String.fromInt y,w=String.fromInt w,h=String.fromInt -h} - else if h>0 - then {x=String.fromInt x,y=String.fromInt y,w=String.fromInt -w,h=String.fromInt h} - else {x=String.fromInt x,y=String.fromInt y,w=String.fromInt -w,h=String.fromInt -h} + else { coords | ry = String.fromInt -ry} + else if ry>0 + then { coords | rx = String.fromInt -rx } + else { coords | rx = String.fromInt -rx, ry = String.fromInt -ry} -- Transformation between elm-types stringToInt : String -> Int stringToInt a = Maybe.withDefault 0 (String.toInt a) -- GitLab