"erp_web/js/pages/git@ustchcs.com:gujinli1118/JSH_ERP.git" did not exist on "247fe119c4deeb647d52f1f85275bd71e993deed"
Commit e2a64d42 authored by Huang's avatar Huang
Browse files

no commit message

parent 0844dd86
 window.onload = function () {
var paper = Raphael("holder");
//var curve = paper.ellipse(100, 100, 1, 1).attr({"stroke-width": 0, fill: Color.red});
var text = "Betty Botter bought some butter but, she said, the butter's bitter. If I put it in my batter, it will make my batter bitter. But a bit of better butter will make my batter better. So, she bought a bit of butter, better than her bitter butter, and she put it in her batter, and the batter was not bitter. It was better Betty Botter bought a bit better butter.";
var font = {font: "11px Arial", "font-style":"italic", opacity: 1, "fill": LABEL_COLOR, stroke: LABEL_COLOR, "stroke-width":.3};
var font = {font: "11px Arial", opacity: 1, "fill": LABEL_COLOR};
var boxWidth = 100
var AttributedStringIterator = function(text){
//this.text = this.rtrim(this.ltrim(text));
text = text.replace(/(\s)+/, " ");
this.text = this.rtrim(text);
/*
if (beginIndex < 0 || beginIndex > endIndex || endIndex > length()) {
throw new IllegalArgumentException("Invalid substring range");
}
*/
this.beginIndex = 0;
this.endIndex = this.text.length;
this.currentIndex = this.beginIndex;
//console.group("[AttributedStringIterator]");
var i = 0;
var string = this.text;
var fullPos = 0;
//console.log("string: \"" + string + "\", length: " + string.length);
this.startWordOffsets = [];
this.startWordOffsets.push(fullPos);
// TODO: remove i 1000
while (i<1000) {
var pos = string.search(/[ \t\n\f-\.\,]/);
if (pos == -1)
break;
// whitespace start
fullPos += pos;
string = string.substr(pos);
////console.log("fullPos: " + fullPos + ", pos: " + pos + ", string: ", string);
// remove whitespaces
var pos = string.search(/[^ \t\n\f-\.\,]/);
if (pos == -1)
break;
// whitespace end
fullPos += pos;
string = string.substr(pos);
////console.log("fullPos: " + fullPos);
this.startWordOffsets.push(fullPos);
i++;
}
//console.log("startWordOffsets: ", this.startWordOffsets);
//console.groupEnd();
};
AttributedStringIterator.prototype = {
getEndIndex: function(pos){
if (typeof(pos) == "undefined")
return this.endIndex;
var string = this.text.substr(pos, this.endIndex - pos);
var posEndOfLine = string.search(/[\n]/);
if (posEndOfLine == -1)
return this.endIndex;
else
return pos + posEndOfLine;
},
getBeginIndex: function(){
return this.beginIndex;
},
isWhitespace: function(pos){
var str = this.text[pos];
var whitespaceChars = " \t\n\f";
return (whitespaceChars.indexOf(str) != -1);
},
isNewLine: function(pos){
var str = this.text[pos];
var whitespaceChars = "\n";
return (whitespaceChars.indexOf(str) != -1);
},
preceding: function(pos){
//console.group("[AttributedStringIterator.preceding]");
for(var i in this.startWordOffsets) {
var startWordOffset = this.startWordOffsets[i];
if (pos < startWordOffset && i>0) {
//console.log("startWordOffset: " + this.startWordOffsets[i-1]);
//console.groupEnd();
return this.startWordOffsets[i-1];
}
}
//console.log("pos: " + pos);
//console.groupEnd();
return this.startWordOffsets[i];
},
following: function(pos){
//console.group("[AttributedStringIterator.following]");
for(var i in this.startWordOffsets) {
var startWordOffset = this.startWordOffsets[i];
if (pos < startWordOffset && i>0) {
//console.log("startWordOffset: " + this.startWordOffsets[i]);
//console.groupEnd();
return this.startWordOffsets[i];
}
}
//console.log("pos: " + pos);
//console.groupEnd();
return this.startWordOffsets[i];
},
ltrim: function(str){
var patt2=/^\s+/g;
return str.replace(patt2, "");
},
rtrim: function(str){
var patt2=/\s+$/g;
return str.replace(patt2, "");
},
getLayout: function(start, limit){
return this.text.substr(start, limit - start);
},
getCharAtPos: function(pos) {
return this.text[pos];
}
};
/*
var TextMeasurer = function(paper, text, fontAttrs){
this.text = text;
this.paper = paper;
this.fontAttrs = fontAttrs;
this.fStart = this.text.getBeginIndex();
};
TextMeasurer.prototype = {
getLineBreakIndex: function(start, maxAdvance){
var localStart = start - this.fStart;
},
getLayout: function(){
}
}
*/
var LineBreakMeasurer = function(paper, text, fontAttrs){
this.paper = paper;
this.text = new AttributedStringIterator(text);
this.fontAttrs = fontAttrs;
if (this.text.getEndIndex() - this.text.getBeginIndex() < 1) {
throw {message: "Text must contain at least one character.", code: "IllegalArgumentException"};
}
//this.measurer = new TextMeasurer(paper, this.text, this.fontAttrs);
this.limit = this.text.getEndIndex();
this.pos = this.start = this.text.getBeginIndex();
this.rafaelTextObject = this.paper.text(100, 100, this.text.text).attr(fontAttrs).attr("text-anchor", "start");
this.svgTextObject = this.rafaelTextObject[0];
};
LineBreakMeasurer.prototype = {
nextOffset: function(wrappingWidth, offsetLimit, requireNextWord) {
//console.group("[nextOffset]");
var nextOffset = this.pos;
if (this.pos < this.limit) {
if (offsetLimit <= this.pos) {
throw {message: "offsetLimit must be after current position", code: "IllegalArgumentException"};
}
var charAtMaxAdvance = this.getLineBreakIndex(this.pos, wrappingWidth);
//charAtMaxAdvance --;
//console.log("charAtMaxAdvance:", charAtMaxAdvance, ", [" + this.text.getCharAtPos(charAtMaxAdvance) + "]");
if (charAtMaxAdvance == this.limit) {
nextOffset = this.limit;
//console.log("charAtMaxAdvance == this.limit");
} else if (this.text.isNewLine(charAtMaxAdvance)) {
console.log("isNewLine");
nextOffset = charAtMaxAdvance+1;
} else if (this.text.isWhitespace(charAtMaxAdvance)) {
// TODO: find next noSpaceChar
//return nextOffset;
nextOffset = this.text.following(charAtMaxAdvance);
} else {
// Break is in a word; back up to previous break.
/*
var testPos = charAtMaxAdvance + 1;
if (testPos == this.limit) {
console.error("hbz...");
} else {
nextOffset = this.text.preceding(charAtMaxAdvance);
}
*/
nextOffset = this.text.preceding(charAtMaxAdvance);
if (nextOffset <= this.pos) {
nextOffset = Math.max(this.pos+1, charAtMaxAdvance);
}
}
}
if (nextOffset > offsetLimit) {
nextOffset = offsetLimit;
}
//console.log("nextOffset: " + nextOffset);
//console.groupEnd();
return nextOffset;
},
nextLayout: function(wrappingWidth) {
//console.groupCollapsed("[nextLayout]");
if (this.pos < this.limit) {
var requireNextWord = false;
var layoutLimit = this.nextOffset(wrappingWidth, this.limit, requireNextWord);
//console.log("layoutLimit:", layoutLimit);
if (layoutLimit == this.pos) {
//console.groupEnd();
return null;
}
var result = this.text.getLayout(this.pos, layoutLimit);
//console.log("layout: \"" + result + "\"");
// remove end of line
//var posEndOfLine = this.text.getEndIndex(this.pos);
//if (posEndOfLine < result.length)
// result = result.substr(0, posEndOfLine);
this.pos = layoutLimit;
//console.groupEnd();
return result;
} else {
//console.groupEnd();
return null;
}
},
getLineBreakIndex: function(pos, wrappingWidth) {
//console.group("[getLineBreakIndex]");
//console.log("pos:"+pos + ", text: \""+ this.text.text.replace(/\n/g, "_").substr(pos, 1) + "\"");
var bb = this.rafaelTextObject.getBBox();
var charNum = -1;
try {
var svgPoint = this.svgTextObject.getStartPositionOfChar(pos);
//var dot = this.paper.ellipse(svgPoint.x, svgPoint.y, 1, 1).attr({"stroke-width": 0, fill: Color.blue});
svgPoint.x = svgPoint.x + wrappingWidth;
//svgPoint.y = bb.y;
//console.log("svgPoint:", svgPoint);
//var dot = this.paper.ellipse(svgPoint.x, svgPoint.y, 1, 1).attr({"stroke-width": 0, fill: Color.red});
charNum = this.svgTextObject.getCharNumAtPosition(svgPoint);
} catch (e){
console.warn("getStartPositionOfChar error, pos:" + pos);
/*
var testPos = pos + 1;
if (testPos < this.limit) {
return testPos
}
*/
}
//console.log("charNum:", charNum);
if (charNum == -1) {
//console.groupEnd();
return this.text.getEndIndex(pos);
} else {
// When case there is new line between pos and charnum then use this new line
var newLineIndex = this.text.getEndIndex(pos);
if (newLineIndex < charNum ) {
console.log("newLineIndex <= charNum, newLineIndex:"+newLineIndex+", charNum:"+charNum, "\"" + this.text.text.substr(newLineIndex+1).replace(/\n/g, "") + "\"");
//console.groupEnd();
return newLineIndex;
}
//var charAtMaxAdvance = this.text.text.substring(charNum, charNum + 1);
var charAtMaxAdvance = this.text.getCharAtPos(charNum);
//console.log("!!charAtMaxAdvance: " + charAtMaxAdvance);
//console.groupEnd();
return charNum;
}
},
getPosition: function() {
return this.pos;
}
};
// ******
function drawMultilineText(text, x, y, boxWidth, boxHeight, options) {
var TEXT_PADDING = 3;
var width = boxWidth - (2 * TEXT_PADDING);
if (boxHeight)
var height = boxHeight - (2 * TEXT_PADDING);
var layouts = [];
var measurer = new LineBreakMeasurer(paper, text, font);
var lineHeight = measurer.rafaelTextObject.getBBox().height;
console.log("text: ", text.replace(/\n/g, ""));
if (height) {
var availableLinesCount = parseInt(height/lineHeight);
console.log("availableLinesCount: " + availableLinesCount);
}
var i = 1;
while (measurer.getPosition() < measurer.text.getEndIndex()) {
var layout = measurer.nextLayout(width);
//console.log("LAYOUT: " + layout + ", getPosition: " + measurer.getPosition());
if (layout != null) {
if (!availableLinesCount || i < availableLinesCount) {
layouts.push(layout);
} else {
layouts.push(fitTextToWidth(layout + "...", boxWidth));
break;
}
}
i++;
};
console.log(layouts);
measurer.rafaelTextObject.attr({"text": layouts.join("\n")});
//measurer.rafaelTextObject.attr({"text-anchor": "end"});
//measurer.rafaelTextObject.attr({"text-anchor": "middle"});
if (options)
measurer.rafaelTextObject.attr({"text-anchor": options["text-anchor"]});
var bb = measurer.rafaelTextObject.getBBox();
//measurer.rafaelTextObject.attr({"x": x + boxWidth/2});
if (options["vertical-align"] == "top")
measurer.rafaelTextObject.attr({"y": y + bb.height/2 + TEXT_PADDING});
else
measurer.rafaelTextObject.attr({"y": y + height/2});
//var bb = measurer.rafaelTextObject.getBBox();
if (measurer.rafaelTextObject.attr("text-anchor") == "middle" )
measurer.rafaelTextObject.attr("x", x + boxWidth/2 + TEXT_PADDING/2);
else if (measurer.rafaelTextObject.attr("text-anchor") == "end" )
measurer.rafaelTextObject.attr("x", x + boxWidth + TEXT_PADDING/2);
else
measurer.rafaelTextObject.attr("x", x + boxWidth/2 - bb.width/2 + TEXT_PADDING/2);
var boxStyle = {stroke: Color.LightSteelBlue2, "stroke-width": 1.0, "stroke-dasharray": "- "};
/*
var box = paper.rect(x+.0 + boxWidth/2 - bb.width/2+ TEXT_PADDING/2, y + .5 + boxHeight/2 - bb.height/2, width, height).attr(boxStyle);
box.attr("height", bb.height);
*/
//var box = paper.rect(bb.x - .5 + bb.width/2 + TEXT_PADDING, bb.y + bb.height/2, bb.width, bb.height).attr(boxStyle);
var textAreaCX = x + boxWidth/2;
var textAreaCY = y + height/2;
var dotLeftTop = paper.ellipse(x, y, 3, 3).attr({"stroke-width": 0, fill: Color.LightSteelBlue, stroke: "none"});
var dotCenter = paper.ellipse(textAreaCX, textAreaCY, 3, 3).attr({fill: Color.LightSteelBlue2, stroke: "none"});
/*
// real bbox
var bb = measurer.rafaelTextObject.getBBox();
var rect = paper.rect(bb.x+.5, bb.y + .5, bb.width, bb.height).attr({"stroke-width": 1});
*/
var boxStyle = {stroke: Color.LightSteelBlue2, "stroke-width": 1.0, "stroke-dasharray": "- "};
var rect = paper.rect(x+.5, y + .5, boxWidth, boxHeight).attr(boxStyle);
}
/*
for (var i=0; i<1; i++) {
var t = text;
//var t = "Высококвалифицирова";
var text = paper.text(300, 100, t).attr(font).attr("text-anchor", "start");
var bbText = text.getBBox();
paper.rect(300+.5, 100 + .5, bbText.width, bbText.height).attr({"stroke-width": 1});
console.log("t: ", t.replace(/\n/g, "↵"));
while (measurer.getPosition() < measurer.text.getEndIndex()) {
var layout = measurer.nextLayout(width);
//console.log("LAYOUT: " + layout + ", getPosition: " + measurer.getPosition());
if (layout != null)
layouts.push(layout);
};
measurer.rafaelTextObject.attr("text", layouts.join("\n"));
var bb = measurer.rafaelTextObject.getBBox();
var rect = paper.rect(bb.x+.5, bb.y + .5, bb.width, bb.height).attr({"stroke-width": 1});
lay.push(layouts);
console.log(layouts);
}
*/
var fitTextToWidth = function(original, width) {
var text = original;
// TODO: move attr on parameters
var attr = {font: "11px Arial", opacity: 0};
// remove length for "..."
var dots = paper.text(0, 0, "...").attr(attr).hide();
var dotsBB = dots.getBBox();
var maxWidth = width - dotsBB.width;
var textElement = paper.text(0, 0, text).attr(attr).hide();
var bb = textElement.getBBox();
// it's a little bit incorrect with "..."
while (bb.width > maxWidth && text.length > 0) {
text = text.substring(0, text.length - 1);
textElement.attr({"text": text});
bb = textElement.getBBox();
}
// remove element from paper
textElement.remove();
if (text != original) {
text = text + "...";
}
return text;
}
var x=100, y=90, height=20;
var options = {"text-anchor": "middle", "boxHeight": 150, "vertical-align": "top"};
var options = {"boxHeight": 150, "vertical-align": "top"};
drawMultilineText(text, x, y, 150, 100, options);
};
\ No newline at end of file
body { background: #fafafa; color: #708090; /* font: 300 100.1% "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; */ font-family: Verdana, sans-serif, Arial; font-size: 10px;}.wrapper{ height: 100%; position: relative; width: 100%;}/* #holder { height: 480px; width: 640px; b_ackground: #F8F8FF; -moz-border-radius: 10px; -webkit-border-radius: 10px; -webkit-box-shadow: 0 1px 3px #666; background: #DDD url(./images/bg.png); /* background: #DDD url(./images/checker-bg.png); * / b_order:0px solid #dedede; } */div.diagramHolder { float:left; }div.diagram{ border:1px solid #dedede; margin: 5px; padding: 5px; background: #FFF;}div.diagram.hidden{ display:none;}svg { background: #DDD url(./images/bg.png);} div.diagram-info { float:left; position: relative; padding: 5px;} /* Breadcrumbs */ #diagramBreadCrumbs { margin-left: 2px; margin-right: 2px; margin-top: 10px;}#diagramBreadCrumbs ul { list-style: none; background-color: white; border: 1px solid #DEDEDE; border-color: #C0C2C5; margin: 0; margin-bottom: 10px; margin-left: 0; -webkit-padding-start: 0px; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;}#diagramBreadCrumbs li { /*text-decoration: underline;*/ display: inline-block; vertical-align: middle; padding-left: .75em; padding-right: 0; cursor: pointer;}#diagramBreadCrumbs li.selected { color: #9370DB; color: #4876FF; color: #4F94CD; font-weight: bold;}#diagramBreadCrumbs li span { background: url(images/breadcrumbs.png) no-repeat 100% 50%; display: block; padding: .5em 15px .5em 0;} /* Progress bar */ .ui-progressbar { height: 25px; /*height:2em; text-align: left; overflow: hidden; */ background: white; border: 1px solid #949DAD; margin: 2px; overflow: hidden; padding: 1px; position: relative; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;}.ui-progressbar .ui-progressbar-value { m_argin: -1px; height:100%; background: #D4E4FF; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;}.ui-widget-header a { color: #222222/*{fcHeader}*/; } .ui-progressbar .ui-progressbar-label{ position: absolute; margin-top: 7px; border:0px solid red; width: 100%; text-align: center;}
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
'use strict';
var ACTIVITI = ACTIVITI || {};
ACTIVITI.CONFIG = {
'contextRoot' : appContextRoot+'/service',
};
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
'use strict';
var activitiModeler = angular.module('activitiModeler', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute',
'ngDragDrop',
'mgcrea.ngStrap',
'ngGrid',
'ngAnimate',
'pascalprecht.translate',
'duScroll'
]);
var activitiModule = activitiModeler;
activitiModeler
// Initialize routes
.config(['$selectProvider', '$translateProvider', function ($selectProvider, $translateProvider) {
// Override caret for bs-select directive
angular.extend($selectProvider.defaults, {
caretHtml: '&nbsp;<i class="icon icon-caret-down"></i>'
});
// Initialize angular-translate
$translateProvider.useStaticFilesLoader({
prefix: './editor-app/i18n/',
suffix: '.json'
});
$translateProvider.preferredLanguage('en');
// remember language
$translateProvider.useCookieStorage();
}])
.run(['$rootScope', '$timeout', '$modal', '$translate', '$location', '$window', '$http', '$q',
function($rootScope, $timeout, $modal, $translate, $location, $window, $http, $q) {
$rootScope.config = ACTIVITI.CONFIG;
$rootScope.editorInitialized = false;
$rootScope.editorFactory = $q.defer();
$rootScope.forceSelectionRefresh = false;
$rootScope.ignoreChanges = false; // by default never ignore changes
$rootScope.validationErrors = [];
$rootScope.staticIncludeVersion = Date.now();
/**
* A 'safer' apply that avoids concurrent updates (which $apply allows).
*/
$rootScope.safeApply = function(fn) {
var phase = this.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
if(fn && (typeof(fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
};
/**
* Initialize the event bus: couple all Oryx events with a dispatch of the
* event of the event bus. This way, it gets much easier to attach custom logic
* to any event.
*/
/* Helper method to fetch model from server (always needed) */
function fetchModel(modelId) {
var modelUrl = KISBPM.URL.getModel(modelId);
$http({method: 'GET', url: modelUrl}).
success(function (data, status, headers, config) {
$rootScope.editor = new ORYX.Editor(data);
$rootScope.modelData = angular.fromJson(data);
$rootScope.editorFactory.resolve();
}).
error(function (data, status, headers, config) {
console.log('Error loading model with id ' + modelId + ' ' + data);
});
}
function initScrollHandling() {
var canvasSection = jQuery('#canvasSection');
canvasSection.scroll(function() {
// Hides the resizer and quick menu items during scrolling
var selectedElements = $rootScope.editor.selection;
var subSelectionElements = $rootScope.editor._subSelection;
$rootScope.selectedElements = selectedElements;
$rootScope.subSelectionElements = subSelectionElements;
if (selectedElements && selectedElements.length > 0) {
$rootScope.selectedElementBeforeScrolling = selectedElements[0];
}
jQuery('.Oryx_button').each(function(i, obj) {
$rootScope.orginalOryxButtonStyle = obj.style.display;
obj.style.display = 'none';
});
jQuery('.resizer_southeast').each(function(i, obj) {
$rootScope.orginalResizerSEStyle = obj.style.display;
obj.style.display = 'none';
});
jQuery('.resizer_northwest').each(function(i, obj) {
$rootScope.orginalResizerNWStyle = obj.style.display;
obj.style.display = 'none';
});
$rootScope.editor.handleEvents({type:ORYX.CONFIG.EVENT_CANVAS_SCROLL});
});
canvasSection.scrollStopped(function(){
// Puts the quick menu items and resizer back when scroll is stopped.
$rootScope.editor.setSelection([]); // needed cause it checks for element changes and does nothing if the elements are the same
$rootScope.editor.setSelection($rootScope.selectedElements, $rootScope.subSelectionElements);
$rootScope.selectedElements = undefined;
$rootScope.subSelectionElements = undefined;
function handleDisplayProperty(obj) {
if (jQuery(obj).position().top > 0) {
obj.style.display = 'block';
} else {
obj.style.display = 'none';
}
}
jQuery('.Oryx_button').each(function(i, obj) {
handleDisplayProperty(obj);
});
jQuery('.resizer_southeast').each(function(i, obj) {
handleDisplayProperty(obj);
});
jQuery('.resizer_northwest').each(function(i, obj) {
handleDisplayProperty(obj);
});
});
}
/**
* Initialize the Oryx Editor when the content has been loaded
*/
$rootScope.$on('$includeContentLoaded', function (event) {
if (!$rootScope.editorInitialized) {
ORYX._loadPlugins();
var modelId = EDITOR.UTIL.getParameterByName('modelId');
fetchModel(modelId);
$rootScope.window = {};
var updateWindowSize = function() {
$rootScope.window.width = $window.innerWidth;
$rootScope.window.height = $window.innerHeight;
};
// Window resize hook
angular.element($window).bind('resize', function() {
$rootScope.safeApply(updateWindowSize());
});
$rootScope.$watch('window.forceRefresh', function(newValue) {
if(newValue) {
$timeout(function() {
updateWindowSize();
$rootScope.window.forceRefresh = false;
});
}
});
updateWindowSize();
// Hook in resizing of main panels when window resizes
// TODO: perhaps move to a separate JS-file?
jQuery(window).resize(function () {
// Calculate the offset based on the bottom of the module header
var offset = jQuery("#editor-header").offset();
var propSectionHeight = jQuery('#propertySection').height();
var canvas = jQuery('#canvasSection');
var mainHeader = jQuery('#main-header');
if (offset == undefined || offset === null
|| propSectionHeight === undefined || propSectionHeight === null
|| canvas === undefined || canvas === null || mainHeader === null) {
return;
}
if ($rootScope.editor)
{
var selectedElements = $rootScope.editor.selection;
var subSelectionElements = $rootScope.editor._subSelection;
$rootScope.selectedElements = selectedElements;
$rootScope.subSelectionElements = subSelectionElements;
if (selectedElements && selectedElements.length > 0)
{
$rootScope.selectedElementBeforeScrolling = selectedElements[0];
$rootScope.editor.setSelection([]); // needed cause it checks for element changes and does nothing if the elements are the same
$rootScope.editor.setSelection($rootScope.selectedElements, $rootScope.subSelectionElements);
$rootScope.selectedElements = undefined;
$rootScope.subSelectionElements = undefined;
}
}
// var totalAvailable = jQuery(window).height() - offset.top - mainHeader.height() - 21;
var totalAvailable = jQuery(window).height() - offset.top - mainHeader.height() - 42; // 隐藏顶部标题栏,调整下fix参数 JeeSpring
canvas.height(totalAvailable - propSectionHeight);
jQuery('#paletteSection').height(totalAvailable);
// Update positions of the resize-markers, according to the canvas
var actualCanvas = null;
if (canvas && canvas[0].children[1]) {
actualCanvas = canvas[0].children[1];
}
var canvasTop = canvas.position().top;
var canvasLeft = canvas.position().left;
var canvasHeight = canvas[0].clientHeight;
var canvasWidth = canvas[0].clientWidth;
var iconCenterOffset = 8;
var widthDiff = 0;
var actualWidth = 0;
if(actualCanvas) {
// In some browsers, the SVG-element clientwidth isn't available, so we revert to the parent
actualWidth = actualCanvas.clientWidth || actualCanvas.parentNode.clientWidth;
}
if(actualWidth < canvas[0].clientWidth) {
widthDiff = actualWidth - canvas[0].clientWidth;
// In case the canvas is smaller than the actual viewport, the resizers should be moved
canvasLeft -= widthDiff / 2;
canvasWidth += widthDiff;
}
var iconWidth = 17;
var iconOffset = 20;
var north = jQuery('#canvas-grow-N');
north.css('top', canvasTop + iconOffset + 'px');
north.css('left', canvasLeft - 10 + (canvasWidth - iconWidth) / 2 + 'px');
var south = jQuery('#canvas-grow-S');
south.css('top', (canvasTop + canvasHeight - iconOffset - iconCenterOffset) + 'px');
south.css('left', canvasLeft - 10 + (canvasWidth - iconWidth) / 2 + 'px');
var east = jQuery('#canvas-grow-E');
east.css('top', canvasTop - 10 + (canvasHeight - iconWidth) / 2 + 'px');
east.css('left', (canvasLeft + canvasWidth - iconOffset - iconCenterOffset) + 'px');
var west = jQuery('#canvas-grow-W');
west.css('top', canvasTop -10 + (canvasHeight - iconWidth) / 2 + 'px');
west.css('left', canvasLeft + iconOffset + 'px');
north = jQuery('#canvas-shrink-N');
north.css('top', canvasTop + iconOffset + 'px');
north.css('left', canvasLeft + 10 + (canvasWidth - iconWidth) / 2 + 'px');
south = jQuery('#canvas-shrink-S');
south.css('top', (canvasTop + canvasHeight - iconOffset - iconCenterOffset) + 'px');
south.css('left', canvasLeft +10 + (canvasWidth - iconWidth) / 2 + 'px');
east = jQuery('#canvas-shrink-E');
east.css('top', canvasTop + 10 + (canvasHeight - iconWidth) / 2 + 'px');
east.css('left', (canvasLeft + canvasWidth - iconOffset - iconCenterOffset) + 'px');
west = jQuery('#canvas-shrink-W');
west.css('top', canvasTop + 10 + (canvasHeight - iconWidth) / 2 + 'px');
west.css('left', canvasLeft + iconOffset + 'px');
});
jQuery(window).trigger('resize');
jQuery.fn.scrollStopped = function(callback) {
jQuery(this).scroll(function(){
var self = this, $this = jQuery(self);
if ($this.data('scrollTimeout')) {
clearTimeout($this.data('scrollTimeout'));
}
$this.data('scrollTimeout', setTimeout(callback,50,self));
});
};
// Always needed, cause the DOM element on which the scroll event listeners are attached are changed for every new model
initScrollHandling();
$rootScope.editorInitialized = true;
}
});
/**
* Initialize the event bus: couple all Oryx events with a dispatch of the
* event of the event bus. This way, it gets much easier to attach custom logic
* to any event.
*/
$rootScope.editorFactory.promise.then(function() {
KISBPM.eventBus.editor = $rootScope.editor;
var eventMappings = [
{ oryxType : ORYX.CONFIG.EVENT_SELECTION_CHANGED, kisBpmType : KISBPM.eventBus.EVENT_TYPE_SELECTION_CHANGE },
{ oryxType : ORYX.CONFIG.EVENT_DBLCLICK, kisBpmType : KISBPM.eventBus.EVENT_TYPE_DOUBLE_CLICK },
{ oryxType : ORYX.CONFIG.EVENT_MOUSEOUT, kisBpmType : KISBPM.eventBus.EVENT_TYPE_MOUSE_OUT },
{ oryxType : ORYX.CONFIG.EVENT_MOUSEOVER, kisBpmType : KISBPM.eventBus.EVENT_TYPE_MOUSE_OVER }
];
eventMappings.forEach(function(eventMapping) {
$rootScope.editor.registerOnEvent(eventMapping.oryxType, function(event) {
KISBPM.eventBus.dispatch(eventMapping.kisBpmType, event);
});
});
$rootScope.editor.registerOnEvent(ORYX.CONFIG.EVENT_SHAPEREMOVED, function (event) {
var validateButton = document.getElementById(event.shape.resourceId + "-validate-button");
if (validateButton)
{
validateButton.style.display = 'none';
}
});
// The Oryx canvas is ready (we know since we're in this promise callback) and the
// event bus is ready. The editor is now ready for use
KISBPM.eventBus.dispatch(KISBPM.eventBus.EVENT_TYPE_EDITOR_READY, {type : KISBPM.eventBus.EVENT_TYPE_EDITOR_READY});
});
// Alerts
$rootScope.alerts = {
queue: []
};
$rootScope.showAlert = function(alert) {
if(alert.queue.length > 0) {
alert.current = alert.queue.shift();
// Start timout for message-pruning
alert.timeout = $timeout(function() {
if (alert.queue.length == 0) {
alert.current = undefined;
alert.timeout = undefined;
} else {
$rootScope.showAlert(alert);
}
}, (alert.current.type == 'error' ? 5000 : 1000));
} else {
$rootScope.alerts.current = undefined;
}
};
$rootScope.addAlert = function(message, type) {
var newAlert = {message: message, type: type};
if (!$rootScope.alerts.timeout) {
// Timeout for message queue is not running, start one
$rootScope.alerts.queue.push(newAlert);
$rootScope.showAlert($rootScope.alerts);
} else {
$rootScope.alerts.queue.push(newAlert);
}
};
$rootScope.dismissAlert = function() {
if (!$rootScope.alerts.timeout) {
$rootScope.alerts.current = undefined;
} else {
$timeout.cancel($rootScope.alerts.timeout);
$rootScope.alerts.timeout = undefined;
$rootScope.showAlert($rootScope.alerts);
}
};
$rootScope.addAlertPromise = function(promise, type) {
if (promise) {
promise.then(function(data) {
$rootScope.addAlert(data, type);
});
}
};
}
])
// Moment-JS date-formatting filter
.filter('dateformat', function() {
return function(date, format) {
if (date) {
if (format) {
return moment(date).format(format);
} else {
return moment(date).calendar();
}
}
return '';
};
});
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Assignment
*/
var KisBpmAssignmentCtrl = [ '$scope', '$modal', function($scope, $modal) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/assignment-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmAssignmentPopupCtrl = [ '$scope', function($scope) {
// Put json representing assignment on scope
if ($scope.property.value !== undefined && $scope.property.value !== null
&& $scope.property.value.assignment !== undefined
&& $scope.property.value.assignment !== null)
{
$scope.assignment = $scope.property.value.assignment;
} else {
$scope.assignment = {};
}
if ($scope.assignment.candidateUsers == undefined || $scope.assignment.candidateUsers.length == 0)
{
$scope.assignment.candidateUsers = [{value: ''}];
}
// Click handler for + button after enum value
var userValueIndex = 1;
$scope.addCandidateUserValue = function(index) {
$scope.assignment.candidateUsers.splice(index + 1, 0, {value: 'value ' + userValueIndex++});
};
// Click handler for - button after enum value
$scope.removeCandidateUserValue = function(index) {
$scope.assignment.candidateUsers.splice(index, 1);
};
if ($scope.assignment.candidateGroups == undefined || $scope.assignment.candidateGroups.length == 0)
{
$scope.assignment.candidateGroups = [{value: ''}];
}
var groupValueIndex = 1;
$scope.addCandidateGroupValue = function(index) {
$scope.assignment.candidateGroups.splice(index + 1, 0, {value: 'value ' + groupValueIndex++});
};
// Click handler for - button after enum value
$scope.removeCandidateGroupValue = function(index) {
$scope.assignment.candidateGroups.splice(index, 1);
};
$scope.save = function() {
$scope.property.value = {};
handleAssignmentInput($scope);
$scope.property.value.assignment = $scope.assignment;
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
// Close button handler
$scope.close = function() {
handleAssignmentInput($scope);
$scope.property.mode = 'read';
$scope.$hide();
};
var handleAssignmentInput = function($scope) {
if ($scope.assignment.candidateUsers)
{
var emptyUsers = true;
var toRemoveIndexes = [];
for (var i = 0; i < $scope.assignment.candidateUsers.length; i++)
{
if ($scope.assignment.candidateUsers[i].value != '')
{
emptyUsers = false;
}
else
{
toRemoveIndexes[toRemoveIndexes.length] = i;
}
}
for (var i = 0; i < toRemoveIndexes.length; i++)
{
$scope.assignment.candidateUsers.splice(toRemoveIndexes[i], 1);
}
if (emptyUsers)
{
$scope.assignment.candidateUsers = undefined;
}
}
if ($scope.assignment.candidateGroups)
{
var emptyGroups = true;
var toRemoveIndexes = [];
for (var i = 0; i < $scope.assignment.candidateGroups.length; i++)
{
if ($scope.assignment.candidateGroups[i].value != '')
{
emptyGroups = false;
}
else
{
toRemoveIndexes[toRemoveIndexes.length] = i;
}
}
for (var i = 0; i < toRemoveIndexes.length; i++)
{
$scope.assignment.candidateGroups.splice(toRemoveIndexes[i], 1);
}
if (emptyGroups)
{
$scope.assignment.candidateGroups = undefined;
}
}
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Condition expression
*/
var KisBpmConditionExpressionCtrl = [ '$scope', '$modal', function($scope, $modal) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/condition-expression-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmConditionExpressionPopupCtrl = [ '$scope', '$translate', '$http', function($scope, $translate, $http) {
// Put json representing condition on scope
if ($scope.property.value !== undefined && $scope.property.value !== null) {
$scope.conditionExpression = {value: $scope.property.value};
} else {
$scope.conditionExpression = {value: ''};
}
$scope.save = function() {
$scope.property.value = $scope.conditionExpression.value;
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
// Close button handler
$scope.close = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* String controller
*/
var KisBpmStringPropertyCtrl = [ '$scope', function ($scope) {
$scope.shapeId = $scope.selectedShape.id;
$scope.valueFlushed = false;
/** Handler called when input field is blurred */
$scope.inputBlurred = function() {
$scope.valueFlushed = true;
if ($scope.property.value) {
$scope.property.value = $scope.property.value.replace(/(<([^>]+)>)/ig,"");
}
$scope.updatePropertyInModel($scope.property);
};
$scope.enterPressed = function(keyEvent) {
if (keyEvent && keyEvent.which === 13) {
keyEvent.preventDefault();
$scope.inputBlurred(); // we want to do the same as if the user would blur the input field
}
};
$scope.$on('$destroy', function controllerDestroyed() {
if(!$scope.valueFlushed) {
if ($scope.property.value) {
$scope.property.value = $scope.property.value.replace(/(<([^>]+)>)/ig,"");
}
$scope.updatePropertyInModel($scope.property, $scope.shapeId);
}
});
}];
/*
* Boolean controller
*/
var KisBpmBooleanPropertyCtrl = ['$scope', function ($scope) {
$scope.changeValue = function() {
if ($scope.property.key === 'oryx-defaultflow' && $scope.property.value) {
var selectedShape = $scope.selectedShape;
if (selectedShape) {
var incomingNodes = selectedShape.getIncomingShapes();
if (incomingNodes && incomingNodes.length > 0) {
// get first node, since there can be only one for a sequence flow
var rootNode = incomingNodes[0];
var flows = rootNode.getOutgoingShapes();
if (flows && flows.length > 1) {
// in case there are more flows, check if another flow is already defined as default
for (var i = 0; i < flows.length; i++) {
if (flows[i].resourceId != selectedShape.resourceId) {
var defaultFlowProp = flows[i].properties['oryx-defaultflow'];
if (defaultFlowProp) {
flows[i].setProperty('oryx-defaultflow', false, true);
}
}
}
}
}
}
}
$scope.updatePropertyInModel($scope.property);
};
}];
/*
* Text controller
*/
var KisBpmTextPropertyCtrl = [ '$scope', '$modal', function($scope, $modal) {
var opts = {
template: 'editor-app/configuration/properties/text-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmTextPropertyPopupCtrl = ['$scope', function($scope) {
$scope.save = function() {
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.close = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Execution listeners
*/
var KisBpmEventListenersCtrl = [ '$scope', '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/event-listeners-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
//Need a separate controller for the modal window due to https://github.com/angular-ui/bootstrap/issues/259
// Will be fixed in a newer version of Angular UI
var KisBpmEventListenersPopupCtrl = [ '$scope', '$q', '$translate', function($scope, $q, $translate) {
// Put json representing form properties on scope
if ($scope.property.value !== undefined && $scope.property.value !== null
&& $scope.property.value.eventListeners !== undefined
&& $scope.property.value.eventListeners !== null) {
if ($scope.property.value.eventListeners.constructor == String)
{
$scope.eventListeners = JSON.parse($scope.property.value.eventListeners);
}
else
{
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happened
$scope.eventListeners = angular.copy($scope.property.value.eventListeners);
}
} else {
$scope.eventListeners = [];
}
// Array to contain selected properties (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedListeners = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var eventPromise = $translate('PROPERTY.EXECUTIONLISTENERS.EVENT');
var implementationPromise = $translate('PROPERTY.EXECUTIONLISTENERS.FIELDS.IMPLEMENTATION');
var namePromise = $translate('PROPERTY.EXECUTIONLISTENERS.FIELDS.NAME');
$q.all([eventPromise, implementationPromise, namePromise]).then(function(results) {
$scope.labels.eventLabel = results[0];
$scope.labels.implementationLabel = results[1];
$scope.labels.nameLabel = results[2];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'eventListeners',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedListeners,
afterSelectionChange: function (rowItem, event) {
if ($scope.selectedListeners.length > 0)
{
var fields = $scope.selectedListeners[0].fields;
if (fields !== undefined && fields !== null)
{
for (var i = 0; i < fields.length; i++)
{
var field = fields[i];
if (field.stringValue !== undefined && field.stringValue !== '')
{
field.implementation = field.stringValue;
}
else if (field.expression !== undefined && field.expression !== '')
{
field.implementation = field.expression;
}
else if (field.string !== undefined && field.string !== '')
{
field.implementation = field.string;
}
}
}
if (!$scope.selectedListeners[0].events || $scope.selectedListeners[0].events.length == 0)
{
$scope.selectedListeners[0].events = [{event: ''}];
}
}
},
columnDefs: [{ field: 'event', displayName: $scope.labels.eventLabel },
{ field: 'implementation', displayName: $scope.labels.implementationLabel }]
};
});
// Click handler for + button after enum value
$scope.addEventValue = function(index) {
$scope.selectedListeners[0].events.splice(index + 1, 0, {event: ''});
};
// Click handler for - button after enum value
$scope.removeEventValue = function(index) {
$scope.selectedListeners[0].events.splice(index, 1);
$scope.listenerDetailsChanged();
};
$scope.listenerDetailsChanged = function() {
var listener = $scope.selectedListeners[0];
if (listener.events)
{
var eventText = '';
for (var i = 0; i < listener.events.length; i++)
{
if (i > 0)
{
eventText += ", ";
}
eventText += listener.events[i].event;
}
$scope.selectedListeners[0].event = eventText;
}
if (listener.rethrowEvent)
{
var implementationText = '';
if (listener.rethrowType && listener.rethrowType.length > 0)
{
if (listener.rethrowType === 'error' && listener.errorcode !== '')
{
implementationText = "Rethrow as error " + listener.errorcode;
}
else if (listener.rethrowType === 'message' && listener.messagename !== '')
{
implementationText = "Rethrow as message " + listener.messagename;
}
else if ((listener.rethrowType === 'signal' || listener.rethrowType === 'globalSignal') && listener.signalname !== '')
{
implementationText = "Rethrow as signal " + listener.signalname;
}
}
$scope.selectedListeners[0].implementation = implementationText;
}
else
{
if ($scope.selectedListeners[0].className !== '')
{
$scope.selectedListeners[0].implementation = $scope.selectedListeners[0].className;
}
else if ($scope.selectedListeners[0].delegateExpression !== '')
{
$scope.selectedListeners[0].implementation = $scope.selectedListeners[0].delegateExpression;
}
else
{
$scope.selectedListeners[0].implementation = '';
}
}
};
// Click handler for add button
$scope.addNewListener = function() {
$scope.eventListeners.push({ event : '',
implementation : '',
className : '',
delegateExpression: '',
retrowEvent: false});
};
// Click handler for remove button
$scope.removeListener = function() {
if ($scope.selectedListeners.length > 0) {
var index = $scope.eventListeners.indexOf($scope.selectedListeners[0]);
$scope.gridOptions.selectItem(index, false);
$scope.eventListeners.splice(index, 1);
$scope.selectedListeners.length = 0;
if (index < $scope.eventListeners.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.eventListeners.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for up button
$scope.moveListenerUp = function() {
if ($scope.selectedListeners.length > 0) {
var index = $scope.eventListeners.indexOf($scope.selectedListeners[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.eventListeners[index];
$scope.eventListeners.splice(index, 1);
$timeout(function(){
$scope.eventListeners.splice(index + -1, 0, temp);
}, 100);
}
}
};
// Click handler for down button
$scope.moveListenerDown = function() {
if ($scope.selectedListeners.length > 0) {
var index = $scope.eventListeners.indexOf($scope.selectedListeners[0]);
if (index != $scope.eventListeners.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.eventListeners[index];
$scope.eventListeners.splice(index, 1);
$timeout(function(){
$scope.eventListeners.splice(index + 1, 0, temp);
}, 100);
}
}
};
// Click handler for save button
$scope.save = function() {
if ($scope.eventListeners.length > 0) {
$scope.property.value = {};
$scope.property.value.eventListeners = $scope.eventListeners;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
// Close button handler
$scope.close = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Execution listeners
*/
var KisBpmExecutionListenersCtrl = [ '$scope', '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/execution-listeners-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmExecutionListenersPopupCtrl = [ '$scope', '$q', '$translate', function($scope, $q, $translate) {
// Put json representing form properties on scope
if ($scope.property.value !== undefined && $scope.property.value !== null
&& $scope.property.value.executionListeners !== undefined
&& $scope.property.value.executionListeners !== null) {
if ($scope.property.value.executionListeners.constructor == String)
{
$scope.executionListeners = JSON.parse($scope.property.value.executionListeners);
}
else
{
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happened
$scope.executionListeners = angular.copy($scope.property.value.executionListeners);
}
for (var i = 0; i < $scope.executionListeners.length; i++)
{
var executionListener = $scope.executionListeners[i];
if (executionListener.className !== undefined && executionListener.className !== '')
{
executionListener.implementation = executionListener.className;
}
else if (executionListener.expression !== undefined && executionListener.expression !== '')
{
executionListener.implementation = executionListener.expression;
}
else if (executionListener.delegateExpression !== undefined && executionListener.delegateExpression !== '')
{
executionListener.implementation = executionListener.delegateExpression;
}
}
} else {
$scope.executionListeners = [];
}
// Array to contain selected properties (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedListeners = [];
$scope.selectedFields = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var eventPromise = $translate('PROPERTY.EXECUTIONLISTENERS.EVENT');
var implementationPromise = $translate('PROPERTY.EXECUTIONLISTENERS.FIELDS.IMPLEMENTATION');
var namePromise = $translate('PROPERTY.EXECUTIONLISTENERS.FIELDS.NAME');
$q.all([eventPromise, implementationPromise, namePromise]).then(function(results) {
$scope.labels.eventLabel = results[0];
$scope.labels.implementationLabel = results[1];
$scope.labels.nameLabel = results[2];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'executionListeners',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedListeners,
afterSelectionChange: function (rowItem, event) {
$scope.selectedFields.length = 0;
if ($scope.selectedListeners.length > 0)
{
var fields = $scope.selectedListeners[0].fields;
if (fields !== undefined && fields !== null)
{
for (var i = 0; i < fields.length; i++)
{
var field = fields[i];
if (field.stringValue !== undefined && field.stringValue !== '')
{
field.implementation = field.stringValue;
}
else if (field.expression !== undefined && field.expression !== '')
{
field.implementation = field.expression;
}
else if (field.string !== undefined && field.string !== '')
{
field.implementation = field.string;
}
}
}
}
},
columnDefs: [{ field: 'event', displayName: $scope.labels.eventLabel },
{ field: 'implementation', displayName: $scope.labels.implementationLabel }]
};
// Config for field grid
$scope.gridFieldOptions = {
data: 'selectedListeners[0].fields',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedFields,
columnDefs: [{ field: 'name', displayName: $scope.labels.nameLabel },
{ field: 'implementation', displayName: $scope.labels.implementationLabel}]
};
});
$scope.listenerDetailsChanged = function() {
if ($scope.selectedListeners[0].className !== '')
{
$scope.selectedListeners[0].implementation = $scope.selectedListeners[0].className;
}
else if ($scope.selectedListeners[0].expression !== '')
{
$scope.selectedListeners[0].implementation = $scope.selectedListeners[0].expression;
}
else if ($scope.selectedListeners[0].delegateExpression !== '')
{
$scope.selectedListeners[0].implementation = $scope.selectedListeners[0].delegateExpression;
}
else
{
$scope.selectedListeners[0].implementation = '';
}
};
// Click handler for add button
$scope.addNewListener = function() {
$scope.executionListeners.push({ event : 'start',
implementation : '',
className : '',
expression: '',
delegateExpression: ''});
};
// Click handler for remove button
$scope.removeListener = function() {
if ($scope.selectedListeners.length > 0) {
var index = $scope.executionListeners.indexOf($scope.selectedListeners[0]);
$scope.gridOptions.selectItem(index, false);
$scope.executionListeners.splice(index, 1);
$scope.selectedListeners.length = 0;
if (index < $scope.executionListeners.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.executionListeners.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for up button
$scope.moveListenerUp = function() {
if ($scope.selectedListeners.length > 0) {
var index = $scope.executionListeners.indexOf($scope.selectedListeners[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.executionListeners[index];
$scope.executionListeners.splice(index, 1);
$timeout(function(){
$scope.executionListeners.splice(index + -1, 0, temp);
}, 100);
}
}
};
// Click handler for down button
$scope.moveListenerDown = function() {
if ($scope.selectedListeners.length > 0) {
var index = $scope.executionListeners.indexOf($scope.selectedListeners[0]);
if (index != $scope.executionListeners.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.executionListeners[index];
$scope.executionListeners.splice(index, 1);
$timeout(function(){
$scope.executionListeners.splice(index + 1, 0, temp);
}, 100);
}
}
};
$scope.fieldDetailsChanged = function() {
if ($scope.selectedFields[0].stringValue !== '')
{
$scope.selectedFields[0].implementation = $scope.selectedFields[0].stringValue;
}
else if ($scope.selectedFields[0].expression !== '')
{
$scope.selectedFields[0].implementation = $scope.selectedFields[0].expression;
}
else if ($scope.selectedFields[0].string !== '')
{
$scope.selectedFields[0].implementation = $scope.selectedFields[0].string;
}
else
{
$scope.selectedFields[0].implementation = '';
}
};
// Click handler for add button
$scope.addNewField = function() {
if ($scope.selectedListeners.length > 0)
{
if ($scope.selectedListeners[0].fields == undefined)
{
$scope.selectedListeners[0].fields = [];
}
$scope.selectedListeners[0].fields.push({ name : 'fieldName',
implementation : '',
stringValue : '',
expression: '',
string: ''});
}
};
// Click handler for remove button
$scope.removeField = function() {
if ($scope.selectedFields.length > 0) {
var index = $scope.selectedListeners[0].fields.indexOf($scope.selectedFields[0]);
$scope.gridFieldOptions.selectItem(index, false);
$scope.selectedListeners[0].fields.splice(index, 1);
$scope.selectedFields.length = 0;
if (index < $scope.selectedListeners[0].fields.length) {
$scope.gridFieldOptions.selectItem(index + 1, true);
} else if ($scope.selectedListeners[0].fields.length > 0) {
$scope.gridFieldOptions.selectItem(index - 1, true);
}
}
};
// Click handler for up button
$scope.moveFieldUp = function() {
if ($scope.selectedFields.length > 0) {
var index = $scope.selectedListeners[0].fields.indexOf($scope.selectedFields[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.selectedListeners[0].fields[index];
$scope.selectedListeners[0].fields.splice(index, 1);
$timeout(function(){
$scope.selectedListeners[0].fields.splice(index + -1, 0, temp);
}, 100);
}
}
};
// Click handler for down button
$scope.moveFieldDown = function() {
if ($scope.selectedFields.length > 0) {
var index = $scope.selectedListeners[0].fields.indexOf($scope.selectedFields[0]);
if (index != $scope.selectedListeners[0].fields.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.selectedListeners[0].fields[index];
$scope.selectedListeners[0].fields.splice(index, 1);
$timeout(function(){
$scope.selectedListeners[0].fields.splice(index + 1, 0, temp);
}, 100);
}
}
};
// Click handler for save button
$scope.save = function() {
if ($scope.executionListeners.length > 0) {
$scope.property.value = {};
$scope.property.value.executionListeners = $scope.executionListeners;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function() {
$scope.$hide();
$scope.property.mode = 'read';
};
// Close button handler
$scope.close = function() {
$scope.$hide();
$scope.property.mode = 'read';
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Task listeners
*/
var KisBpmFieldsCtrl = [ '$scope', '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/fields-popup.html',
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmFieldsPopupCtrl = [ '$scope', '$q', '$translate', function($scope, $q, $translate) {
// Put json representing form properties on scope
if ($scope.property.value !== undefined && $scope.property.value !== null
&& $scope.property.value.fields !== undefined
&& $scope.property.value.fields !== null) {
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happened
$scope.fields = angular.copy($scope.property.value.fields);
for (var i = 0; i < $scope.fields.length; i++)
{
var field = $scope.fields[i];
if (field.stringValue !== undefined && field.stringValue !== '')
{
field.implementation = field.stringValue;
}
else if (field.expression !== undefined && field.expression !== '')
{
field.implementation = field.expression;
}
else if (field.string !== undefined && field.string !== '')
{
field.implementation = field.string;
}
}
} else {
$scope.fields = [];
}
// Array to contain selected properties (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedFields = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var namePromise = $translate('PROPERTY.FIELDS.NAME');
var implementationPromise = $translate('PROPERTY.FIELDS.IMPLEMENTATION');
$q.all([namePromise, implementationPromise]).then(function(results) {
$scope.labels.nameLabel = results[0];
$scope.labels.implementationLabel = results[1];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'fields',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected: false,
selectedItems: $scope.selectedFields,
columnDefs: [{field: 'name', displayName: $scope.labels.nameLabel},
{field: 'implementation', displayName: $scope.labels.implementationLabel}]
};
});
$scope.fieldDetailsChanged = function() {
if ($scope.selectedFields[0].stringValue != '')
{
$scope.selectedFields[0].implementation = $scope.selectedFields[0].stringValue;
}
else if ($scope.selectedFields[0].expression != '')
{
$scope.selectedFields[0].implementation = $scope.selectedFields[0].expression;
}
else if ($scope.selectedFields[0].string != '')
{
$scope.selectedFields[0].implementation = $scope.selectedFields[0].string;
}
else
{
$scope.selectedFields[0].implementation = '';
}
};
// Click handler for add button
$scope.addNewField = function() {
$scope.fields.push({ name : 'fieldName',
implementation : '',
stringValue : '',
expression: '',
string: ''});
};
// Click handler for remove button
$scope.removeField = function() {
if ($scope.selectedFields.length > 0) {
var index = $scope.fields.indexOf($scope.selectedFields[0]);
$scope.gridOptions.selectItem(index, false);
$scope.fields.splice(index, 1);
$scope.selectedFields.length = 0;
if (index < $scope.fields.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.fields.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for up button
$scope.moveFieldUp = function() {
if ($scope.selectedFields.length > 0) {
var index = $scope.fields.indexOf($scope.selectedFields[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.fields[index];
$scope.fields.splice(index, 1);
$timeout(function(){
$scope.fields.splice(index + -1, 0, temp);
}, 100);
}
}
};
// Click handler for down button
$scope.moveFieldDown = function() {
if ($scope.selectedFields.length > 0) {
var index = $scope.fields.indexOf($scope.selectedFields[0]);
if (index != $scope.fields.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.fields[index];
$scope.fields.splice(index, 1);
$timeout(function(){
$scope.fields.splice(index + 1, 0, temp);
}, 100);
}
}
};
// Click handler for save button
$scope.save = function() {
if ($scope.fields.length > 0) {
$scope.property.value = {};
$scope.property.value.fields = $scope.fields;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function() {
$scope.close();
};
// Close button handler
$scope.close = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Form Properties
*/
var KisBpmFormPropertiesCtrl = [ '$scope', '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/form-properties-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmFormPropertiesPopupCtrl = ['$scope', '$q', '$translate', '$timeout', function($scope, $q, $translate, $timeout) {
// Put json representing form properties on scope
if ($scope.property.value !== undefined && $scope.property.value !== null
&& $scope.property.value.formProperties !== undefined
&& $scope.property.value.formProperties !== null) {
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happended
$scope.formProperties = angular.copy($scope.property.value.formProperties);
for (var i = 0; i < $scope.formProperties.length; i++) {
var formProperty = $scope.formProperties[i];
if (formProperty.enumValues && formProperty.enumValues.length > 0) {
for (var j = 0; j < formProperty.enumValues.length; j++) {
var enumValue = formProperty.enumValues[j];
if (!enumValue.id && !enumValue.name && enumValue.value) {
enumValue.id = enumValue.value;
enumValue.name = enumValue.value;
}
}
}
}
} else {
$scope.formProperties = [];
}
// Array to contain selected properties (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedProperties = [];
$scope.selectedEnumValues = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var idPromise = $translate('PROPERTY.FORMPROPERTIES.ID');
var namePromise = $translate('PROPERTY.FORMPROPERTIES.NAME');
var typePromise = $translate('PROPERTY.FORMPROPERTIES.TYPE');
$q.all([idPromise, namePromise, typePromise]).then(function(results) {
$scope.labels.idLabel = results[0];
$scope.labels.nameLabel = results[1];
$scope.labels.typeLabel = results[2];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'formProperties',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedProperties,
columnDefs: [{ field: 'id', displayName: $scope.labels.idLabel },
{ field: 'name', displayName: $scope.labels.nameLabel},
{ field: 'type', displayName: $scope.labels.typeLabel}]
};
$scope.enumGridOptions = {
data: 'selectedProperties[0].enumValues',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedEnumValues,
columnDefs: [{ field: 'id', displayName: $scope.labels.idLabel },
{ field: 'name', displayName: $scope.labels.nameLabel}]
}
});
// Handler for when the value of the type dropdown changes
$scope.propertyTypeChanged = function() {
// Check date. If date, show date pattern
if ($scope.selectedProperties[0].type === 'date') {
$scope.selectedProperties[0].datePattern = 'MM-dd-yyyy hh:mm';
} else {
delete $scope.selectedProperties[0].datePattern;
}
// Check enum. If enum, show list of options
if ($scope.selectedProperties[0].type === 'enum') {
$scope.selectedProperties[0].enumValues = [ {id: 'value1', name: 'Value 1'}, {id: 'value2', name: 'Value 2'}];
} else {
delete $scope.selectedProperties[0].enumValues;
}
};
// Click handler for add button
var propertyIndex = 1;
$scope.addNewProperty = function() {
$scope.formProperties.push({ id : 'new_property_' + propertyIndex++,
name : '',
type : 'string',
readable: true,
writable: true});
$timeout(function(){
$scope.gridOptions.selectItem($scope.formProperties.length - 1, true);
});
};
// Click handler for remove button
$scope.removeProperty = function() {
if ($scope.selectedProperties.length > 0) {
var index = $scope.formProperties.indexOf($scope.selectedProperties[0]);
$scope.gridOptions.selectItem(index, false);
$scope.formProperties.splice(index, 1);
$scope.selectedProperties.length = 0;
if (index < $scope.formProperties.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.formProperties.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for up button
$scope.movePropertyUp = function() {
if ($scope.selectedProperties.length > 0) {
var index = $scope.formProperties.indexOf($scope.selectedProperties[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.formProperties[index];
$scope.formProperties.splice(index, 1);
$timeout(function(){
$scope.formProperties.splice(index + -1, 0, temp);
}, 100);
}
}
};
// Click handler for down button
$scope.movePropertyDown = function() {
if ($scope.selectedProperties.length > 0) {
var index = $scope.formProperties.indexOf($scope.selectedProperties[0]);
if (index != $scope.formProperties.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.formProperties[index];
$scope.formProperties.splice(index, 1);
$timeout(function(){
$scope.formProperties.splice(index + 1, 0, temp);
}, 100);
}
}
};
$scope.addNewEnumValue = function() {
if ($scope.selectedProperties.length > 0) {
$scope.selectedProperties[0].enumValues.push({ id : '', name : ''});
}
$timeout(function(){
$scope.enumGridOptions.selectItem($scope.selectedProperties[0].enumValues.length - 1, true);
});
};
// Click handler for remove button
$scope.removeEnumValue = function() {
if ($scope.selectedProperties.length > 0 && $scope.selectedEnumValues.length > 0) {
var index = $scope.selectedProperties[0].enumValues.indexOf($scope.selectedEnumValues[0]);
$scope.enumGridOptions.selectItem(index, false);
$scope.selectedProperties[0].enumValues.splice(index, 1);
$scope.selectedEnumValues.length = 0;
if (index < $scope.selectedProperties[0].enumValues.length) {
$timeout(function(){
$scope.enumGridOptions.selectItem(index + 1, true);
});
} else if ($scope.selectedProperties[0].enumValues.length > 0) {
$timeout(function(){
$scope.enumGridOptions.selectItem(index - 1, true);
});
}
}
};
// Click handler for up button
$scope.moveEnumValueUp = function() {
if ($scope.selectedProperties.length > 0 && $scope.selectedEnumValues.length > 0) {
var index = $scope.selectedProperties[0].enumValues.indexOf($scope.selectedEnumValues[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.selectedProperties[0].enumValues[index];
$scope.selectedProperties[0].enumValues.splice(index, 1);
$timeout(function(){
$scope.selectedProperties[0].enumValues.splice(index + -1, 0, temp);
});
}
}
};
// Click handler for down button
$scope.moveEnumValueDown = function() {
if ($scope.selectedProperties.length > 0 && $scope.selectedEnumValues.length > 0) {
var index = $scope.selectedProperties[0].enumValues.indexOf($scope.selectedEnumValues[0]);
if (index != $scope.selectedProperties[0].enumValues.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.selectedProperties[0].enumValues[index];
$scope.selectedProperties[0].enumValues.splice(index, 1);
$timeout(function(){
$scope.selectedProperties[0].enumValues.splice(index + 1, 0, temp);
});
}
}
};
// Click handler for save button
$scope.save = function() {
if ($scope.formProperties.length > 0) {
$scope.property.value = {};
$scope.property.value.formProperties = $scope.formProperties;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function() {
$scope.$hide();
$scope.property.mode = 'read';
};
// Close button handler
$scope.close = function() {
$scope.$hide();
$scope.property.mode = 'read';
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Input parameters for call activity
*/
var KisBpmInParametersCtrl = [ '$scope', '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/in-parameters-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmInParametersPopupCtrl = ['$scope', '$q', '$translate', function($scope, $q, $translate) {
// Put json representing form properties on scope
if ($scope.property.value !== undefined && $scope.property.value !== null
&& $scope.property.value.inParameters !== undefined
&& $scope.property.value.inParameters !== null) {
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happened
$scope.parameters = angular.copy($scope.property.value.inParameters);
} else {
$scope.parameters = [];
}
// Array to contain selected properties (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedParameters = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var sourcePromise = $translate('PROPERTY.PARAMETER.SOURCE');
var sourceExpressionPromise = $translate('PROPERTY.PARAMETER.SOURCEEXPRESSION');
var targetPromise = $translate('PROPERTY.PARAMETER.TARGET');
$q.all([sourcePromise, sourceExpressionPromise, targetPromise]).then(function(results) {
$scope.labels.sourceLabel = results[0];
$scope.labels.sourceExpressionLabel = results[1];
$scope.labels.targetLabel = results[2];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'parameters',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedParameters,
columnDefs: [{ field: 'source', displayName: $scope.labels.sourceLabel },
{ field: 'sourceExpression', displayName: $scope.labels.sourceExpressionLabel },
{ field: 'target', displayName: $scope.labels.targetLabel }]
};
});
// Click handler for add button
$scope.addNewParameter = function() {
$scope.parameters.push({ source : '',
sourceExpression : '',
target : ''});
};
// Click handler for remove button
$scope.removeParameter = function() {
if ($scope.selectedParameters.length > 0) {
var index = $scope.parameters.indexOf($scope.selectedParameters[0]);
$scope.gridOptions.selectItem(index, false);
$scope.parameters.splice(index, 1);
$scope.selectedParameters.length = 0;
if (index < $scope.parameters.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.parameters.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for up button
$scope.moveParameterUp = function() {
if ($scope.selectedParameters.length > 0) {
var index = $scope.parameters.indexOf($scope.selectedParameters[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.parameters[index];
$scope.parameters.splice(index, 1);
$timeout(function(){
$scope.parameters.splice(index + -1, 0, temp);
}, 100);
}
}
};
// Click handler for down button
$scope.moveParameterDown = function() {
if ($scope.selectedParameters.length > 0) {
var index = $scope.parameters.indexOf($scope.selectedParameters[0]);
if (index != $scope.parameters.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.parameters[index];
$scope.parameters.splice(index, 1);
$timeout(function(){
$scope.parameters.splice(index + 1, 0, temp);
}, 100);
}
}
};
// Click handler for save button
$scope.save = function() {
if ($scope.parameters.length > 0) {
$scope.property.value = {};
$scope.property.value.inParameters = $scope.parameters;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function() {
$scope.close();
};
// Close button handler
$scope.close = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Execution listeners
*/
angular.module('activitiModeler').controller('ActivitiMessageDefinitionsCtrl', ['$scope', '$modal', function ($scope, $modal) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/message-definitions-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}]);
//Need a separate controller for the modal window due to https://github.com/angular-ui/bootstrap/issues/259
// Will be fixed in a newer version of Angular UI
angular.module('activitiModeler').controller('ActivitiMessageDefinitionsPopupCtrl',
['$scope', '$q', '$translate', '$timeout', function ($scope, $q, $translate, $timeout) {
// Put json representing mesage definitions on scope
if ($scope.property.value !== undefined && $scope.property.value !== null && $scope.property.value.length > 0) {
if ($scope.property.value.constructor == String) {
$scope.messageDefinitions = JSON.parse($scope.property.value);
}
else {
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happened
$scope.messageDefinitions = angular.copy($scope.property.value);
}
} else {
$scope.messageDefinitions = [];
}
// Array to contain selected mesage definitions (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedMessages = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var idPromise = $translate('PROPERTY.MESSAGEDEFINITIONS.ID');
var namePromise = $translate('PROPERTY.MESSAGEDEFINITIONS.NAME');
$q.all([idPromise, namePromise]).then(function (results) {
$scope.labels.idLabel = results[0];
$scope.labels.nameLabel = results[1];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'messageDefinitions',
headerRowHeight: 28,
enableRowSelection: true,
enableRowHeaderSelection: false,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedMessages,
columnDefs: [
{field: 'id', displayName: $scope.labels.idLabel},
{field: 'name', displayName: $scope.labels.nameLabel}]
};
});
// Click handler for add button
$scope.addNewMessageDefinition = function () {
var newMessageDefinition = {id: '', name: ''};
$scope.messageDefinitions.push(newMessageDefinition);
$timeout(function () {
$scope.gridOptions.selectItem($scope.messageDefinitions.length - 1, true);
});
};
// Click handler for remove button
$scope.removeMessageDefinition = function () {
if ($scope.selectedMessages && $scope.selectedMessages.length > 0) {
var index = $scope.messageDefinitions.indexOf($scope.selectedMessages[0]);
$scope.gridOptions.selectItem(index, false);
$scope.messageDefinitions.splice(index, 1);
$scope.selectedMessages.length = 0;
if (index < $scope.messageDefinitions.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.messageDefinitions.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for save button
$scope.save = function () {
if ($scope.messageDefinitions.length > 0) {
$scope.property.value = $scope.messageDefinitions;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function () {
$scope.property.mode = 'read';
$scope.$hide();
};
// Close button handler
$scope.close = function () {
$scope.property.mode = 'read';
$scope.$hide();
};
}]);
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
angular.module('activitiModeler').controller('ActivitiMessageRefCtrl', [ '$scope', function($scope) {
// Find the parent shape on which the message definitions are defined
var messageDefinitionsProperty = undefined;
var parent = $scope.selectedShape;
while (parent !== null && parent !== undefined && messageDefinitionsProperty === undefined) {
if (parent.properties && parent.properties['oryx-messagedefinitions']) {
messageDefinitionsProperty = parent.properties['oryx-messagedefinitions'];
} else {
parent = parent.parent;
}
}
try {
messageDefinitionsProperty = JSON.parse(messageDefinitionsProperty);
if (typeof messageDefinitionsProperty == 'string') {
messageDefinitionsProperty = JSON.parse(messageDefinitionsProperty);
}
} catch (err) {
// Do nothing here, just to be sure we try-catch it
}
$scope.messageDefinitions = messageDefinitionsProperty;
$scope.messageChanged = function() {
$scope.updatePropertyInModel($scope.property);
};
}]);
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Execution listeners
*/
var KisBpmMultiInstanceCtrl = [ '$scope', function($scope) {
if ($scope.property.value == undefined && $scope.property.value == null)
{
$scope.property.value = 'None';
}
$scope.multiInstanceChanged = function() {
$scope.updatePropertyInModel($scope.property);
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Input parameters for call activity
*/
var KisBpmOutParametersCtrl = [ '$scope' , '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/out-parameters-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}];
var KisBpmOutParametersPopupCtrl = [ '$scope', '$q', '$translate', function($scope, $q, $translate) {
// Put json representing form properties on scope
if ($scope.property.value !== undefined && $scope.property.value !== null
&& $scope.property.value.outParameters !== undefined
&& $scope.property.value.outParameters !== null) {
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happened
$scope.parameters = angular.copy($scope.property.value.outParameters);
} else {
$scope.parameters = [];
}
// Array to contain selected properties (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedParameters = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var sourcePromise = $translate('PROPERTY.PARAMETER.SOURCE');
var sourceExpressionPromise = $translate('PROPERTY.PARAMETER.SOURCEEXPRESSION');
var targetPromise = $translate('PROPERTY.PARAMETER.TARGET');
$q.all([sourcePromise, sourceExpressionPromise, targetPromise]).then(function(results) {
$scope.labels.sourceLabel = results[0];
$scope.labels.sourceExpressionLabel = results[1];
$scope.labels.targetLabel = results[2];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'parameters',
enableRowReordering: true,
headerRowHeight: 28,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedParameters,
columnDefs: [{ field: 'source', displayName: $scope.labels.sourceLabel },
{ field: 'sourceExpression', displayName: $scope.labels.sourceExpressionLabel },
{ field: 'target', displayName: $scope.labels.targetLabel }]
};
});
// Click handler for add button
$scope.addNewParameter = function() {
$scope.parameters.push({ source : '',
sourceExpression : '',
target : ''});
};
// Click handler for remove button
$scope.removeParameter = function() {
if ($scope.selectedParameters.length > 0) {
var index = $scope.parameters.indexOf($scope.selectedParameters[0]);
$scope.gridOptions.selectItem(index, false);
$scope.parameters.splice(index, 1);
$scope.selectedParameters.length = 0;
if (index < $scope.parameters.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.parameters.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for up button
$scope.moveParameterUp = function() {
if ($scope.selectedParameters.length > 0) {
var index = $scope.parameters.indexOf($scope.selectedParameters[0]);
if (index != 0) { // If it's the first, no moving up of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.parameters[index];
$scope.parameters.splice(index, 1);
$timeout(function(){
$scope.parameters.splice(index + -1, 0, temp);
}, 100);
}
}
};
// Click handler for down button
$scope.moveParameterDown = function() {
if ($scope.selectedParameters.length > 0) {
var index = $scope.parameters.indexOf($scope.selectedParameters[0]);
if (index != $scope.parameters.length - 1) { // If it's the last element, no moving down of course
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272
var temp = $scope.parameters[index];
$scope.parameters.splice(index, 1);
$timeout(function(){
$scope.parameters.splice(index + 1, 0, temp);
}, 100);
}
}
};
// Click handler for save button
$scope.save = function() {
if ($scope.parameters.length > 0) {
$scope.property.value = {};
$scope.property.value.outParameters = $scope.parameters;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function() {
$scope.close();
};
// Close button handler
$scope.close = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Sequence flow order controller
*/
var KisBpmSequenceFlowOrderCtrl = [ '$scope', '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/sequenceflow-order-popup.html?version=' + Date.now(),
scope: $scope
};
$modal(opts);
}];
var KisBpmSequenceFlowOrderPopupCtrl = ['$scope', '$translate', function($scope, $translate) {
// Find the outgoing sequence flow of the current selected shape
var outgoingSequenceFlow = [];
var selectedShape = $scope.selectedShape;
if (selectedShape) {
var outgoingNodes = selectedShape.getOutgoingShapes();
for (var i=0; i<outgoingNodes.length; i++) {
if (outgoingNodes[i].getStencil().title() === 'Sequence flow') {
var targetActivity = outgoingNodes[i].getTarget();
// We need the resourceId of a sequence flow, not the id because that will change with every editor load
outgoingSequenceFlow.push({
id : outgoingNodes[i].resourceId,
targetTitle : targetActivity.properties['oryx-name'],
targetType : targetActivity.getStencil().title()
});
}
}
} else {
console.log('Programmatic error: no selected shape found');
}
// Now we can apply the order which was (possibly) previously saved
var orderedOutgoingSequenceFlow = [];
if ($scope.property.value && $scope.property.value.sequenceFlowOrder) {
var sequenceFlowOrderList = $scope.property.value.sequenceFlowOrder;
// Loop the list of sequence flow that was saved in the json model and match them with the outgoing sequence flow found above
for (var flowIndex=0; flowIndex < sequenceFlowOrderList.length; flowIndex++) {
// find the sequence flow in the outgoing sequence flows.
for (var outgoingFlowIndex=0; outgoingFlowIndex < outgoingSequenceFlow.length; outgoingFlowIndex++) {
if (outgoingSequenceFlow[outgoingFlowIndex].id === sequenceFlowOrderList[flowIndex]) {
orderedOutgoingSequenceFlow.push(outgoingSequenceFlow[outgoingFlowIndex]);
outgoingSequenceFlow.splice(outgoingFlowIndex, 1);
break;
}
}
}
// Now all the matching sequence flow we're removed from the outgoing sequence flow list
// We can simply apply the remaining ones (these are new vs. the time when the values were saved to the model)
orderedOutgoingSequenceFlow = orderedOutgoingSequenceFlow.concat(outgoingSequenceFlow);
} else {
orderedOutgoingSequenceFlow = outgoingSequenceFlow;
}
// Now we can put it on the scope
$scope.outgoingSequenceFlow = orderedOutgoingSequenceFlow;
// Move up click handler
$scope.moveUp = function(index) {
var temp = $scope.outgoingSequenceFlow[index];
$scope.outgoingSequenceFlow[index] = $scope.outgoingSequenceFlow[index - 1];
$scope.outgoingSequenceFlow[index - 1] = temp;
};
// Move down click handler
$scope.moveDown = function(index) {
var temp = $scope.outgoingSequenceFlow[index];
$scope.outgoingSequenceFlow[index] = $scope.outgoingSequenceFlow[index + 1];
$scope.outgoingSequenceFlow[index + 1] = temp;
};
// Save click handler
$scope.save = function() {
if ($scope.outgoingSequenceFlow.length > 0) {
$scope.property.value = {};
$scope.property.value.sequenceFlowOrder = [];
for (var flowIndex=0; flowIndex < $scope.outgoingSequenceFlow.length; flowIndex++) {
$scope.property.value.sequenceFlowOrder.push($scope.outgoingSequenceFlow[flowIndex].id);
}
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
// Cancel click handler
$scope.cancel = function() {
$scope.close();
};
// Close button handler
$scope.close = function() {
$scope.property.mode = 'read';
$scope.$hide();
};
}];
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
angular.module('activitiModeler').controller('ActivitiSignalDefinitionsCtrl', ['$scope', '$modal', function ($scope, $modal) {
// Config for the modal window
var opts = {
template: 'editor-app/configuration/properties/signal-definitions-popup.html?version=' + Date.now(),
scope: $scope
};
// Open the dialog
$modal(opts);
}]);
//Need a separate controller for the modal window due to https://github.com/angular-ui/bootstrap/issues/259
// Will be fixed in a newer version of Angular UI
angular.module('activitiModeler').controller('ActivitiSignalDefinitionsPopupCtrl',
['$scope', '$q', '$translate', '$timeout', function ($scope, $q, $translate, $timeout) {
// Put json representing signal definitions on scope
if ($scope.property.value !== undefined && $scope.property.value !== null && $scope.property.value.length > 0) {
if ($scope.property.value.constructor == String) {
$scope.signalDefinitions = JSON.parse($scope.property.value);
}
else {
// Note that we clone the json object rather then setting it directly,
// this to cope with the fact that the user can click the cancel button and no changes should have happened
$scope.signalDefinitions = angular.copy($scope.property.value);
}
} else {
$scope.signalDefinitions = [];
}
// Array to contain selected signal definitions (yes - we only can select one, but ng-grid isn't smart enough)
$scope.selectedSignals = [];
$scope.translationsRetrieved = false;
$scope.labels = {};
var idPromise = $translate('PROPERTY.SIGNALDEFINITIONS.ID');
var namePromise = $translate('PROPERTY.SIGNALDEFINITIONS.NAME');
var scopePromise = $translate('PROPERTY.SIGNALDEFINITIONS.SCOPE');
$q.all([idPromise, namePromise, scopePromise]).then(function (results) {
$scope.labels.idLabel = results[0];
$scope.labels.nameLabel = results[1];
$scope.labels.scopeLabel = results[2];
$scope.translationsRetrieved = true;
// Config for grid
$scope.gridOptions = {
data: 'signalDefinitions',
headerRowHeight: 28,
enableRowSelection: true,
enableRowHeaderSelection: false,
multiSelect: false,
keepLastSelected : false,
selectedItems: $scope.selectedSignals,
columnDefs: [
{field: 'id', displayName: $scope.labels.idLabel},
{field: 'name', displayName: $scope.labels.nameLabel},
{field: 'scope', displayName: $scope.labels.scopeLabel}]
};
});
// Click handler for add button
$scope.addNewSignalDefinition = function () {
var newSignalDefinition = {id: '', name: '', scope: 'global'};
$scope.signalDefinitions.push(newSignalDefinition);
$timeout(function () {
$scope.gridOptions.selectItem($scope.signalDefinitions.length - 1, true);
});
};
// Click handler for remove button
$scope.removeSignalDefinition = function () {
if ($scope.selectedSignals && $scope.selectedSignals.length > 0) {
var index = $scope.signalDefinitions.indexOf($scope.selectedSignals[0]);
$scope.gridOptions.selectItem(index, false);
$scope.signalDefinitions.splice(index, 1);
$scope.selectedSignals.length = 0;
if (index < $scope.signalDefinitions.length) {
$scope.gridOptions.selectItem(index + 1, true);
} else if ($scope.signalDefinitions.length > 0) {
$scope.gridOptions.selectItem(index - 1, true);
}
}
};
// Click handler for save button
$scope.save = function () {
if ($scope.signalDefinitions.length > 0) {
$scope.property.value = $scope.signalDefinitions;
} else {
$scope.property.value = null;
}
$scope.updatePropertyInModel($scope.property);
$scope.close();
};
$scope.cancel = function () {
$scope.property.mode = 'read';
$scope.$hide();
};
// Close button handler
$scope.close = function () {
$scope.property.mode = 'read';
$scope.$hide();
};
}]);
\ No newline at end of file
/*
* Activiti Modeler component part of the Activiti project
* Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
angular.module('activitiModeler').controller('ActivitiSignalRefCtrl', [ '$scope', function($scope) {
// Find the parent shape on which the signal definitions are defined
var signalDefinitionsProperty = undefined;
var parent = $scope.selectedShape;
while (parent !== null && parent !== undefined && signalDefinitionsProperty === undefined) {
if (parent.properties && parent.properties['oryx-signaldefinitions']) {
signalDefinitionsProperty = parent.properties['oryx-signaldefinitions'];
} else {
parent = parent.parent;
}
}
try {
signalDefinitionsProperty = JSON.parse(signalDefinitionsProperty);
if (typeof signalDefinitionsProperty == 'string') {
signalDefinitionsProperty = JSON.parse(signalDefinitionsProperty);
}
} catch (err) {
// Do nothing here, just to be sure we try-catch it
}
$scope.signalDefinitions = signalDefinitionsProperty;
$scope.signalChanged = function() {
$scope.updatePropertyInModel($scope.property);
};
}]);
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment