Merge branch 'master' of bitbucket.org:richardnoel/processmaker

This commit is contained in:
Richard Yujra
2015-01-15 14:30:00 -04:00
7 changed files with 59 additions and 50 deletions

View File

@@ -42,31 +42,6 @@ class pmDynaform
return $this->record;
}
public function getMergeValues()
{
$dataJSON = G::json_decode($this->record["DYN_CONTENT"]);
$dt = $dataJSON->items[0]->items;
$n = count($dt);
for ($i = 0; $i < $n; $i++) {
$dr = $dt[$i];
$n2 = count($dr);
for ($j = 0; $j < $n2; $j++) {
if (isset($dr[$j]->name)) {
$valueField = isset($this->app_data[$dr[$j]->name]) ? $this->app_data[$dr[$j]->name] : "";
$dataJSON->items[0]->items[$i][$j]->defaultValue = $valueField;
}
}
}
$a = G::json_encode($dataJSON);
$a = str_replace("\/", "/", $a);
return $a;
}
public function mergeValues()
{
$this->record["DYN_CONTENT"] = $this->getMergeValues();
}
public function isResponsive()
{
return $this->record != null && $this->record["DYN_VERSION"] == 2 ? true : false;
@@ -75,12 +50,27 @@ class pmDynaform
public function printView($pm_run_outside_main_app, $application)
{
ob_clean();
$a = $this->clientToken();
$clientToken = array(
"accessToken" => $a["access_token"],
"expiresIn" => $a["expires_in"],
"tokenType" => $a["token_type"],
"scope" => $a["scope"],
"refreshToken" => $a["refresh_token"],
"clientId" => $a["client_id"],
"clientSecret" => $a["client_secret"]
);
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/cases_Step_Pmdynaform_View.html');
$file = str_replace("{JSON_DATA}", $this->record["DYN_CONTENT"], $file);
$file = str_replace("{PM_RUN_OUTSIDE_MAIN_APP}", $pm_run_outside_main_app, $file);
$file = str_replace("{DYN_UID}", $this->dyn_uid, $file);
$file = str_replace("{DYNAFORMNAME}", $this->record["PRO_UID"] . "_" . $this->record["DYN_UID"], $file);
$file = str_replace("{APP_UID}", $application, $file);
$file = str_replace("{PRJ_UID}", $this->app_data["PROCESS"], $file);
$file = str_replace("{WORKSPACE}", $this->app_data["SYS_SYS"], $file);
$file = str_replace("{credentials}", json_encode($clientToken), $file);
echo $file;
exit();
}

View File

@@ -22,18 +22,6 @@ function dynaFormChanged(frm) {
return false;
}
$(window).load(function () {
var data = jsondata;
window.dynaform = new PMDynaform.core.Project({
data: data,
keys: {
server: location.host,
projectId: prj_uid,
workspace: workspace
},
token: credentials,
submitRest: false
});
if (pm_run_outside_main_app === 'true') {
if (parent.showCaseNavigatorPanel) {
parent.showCaseNavigatorPanel('DRAFT');
@@ -44,38 +32,52 @@ $(window).load(function () {
}
}
var form = document.getElementsByTagName("form")[0];
var data = jsondata;
window.project = new PMDynaform.core.Project({
data: data,
keys: {
server: location.host,
projectId: prj_uid,
workspace: workspace
},
token: credentials,
submitRest: false
});
new PMDynaform.core.Proxy({
url: "http://" + window.project.keys.server + "/" + window.project.keys.apiName + "/" + window.project.keys.apiVersion + "/" + window.project.keys.workspace + "/cases/" + app_uid + "/variables",
method: 'GET',
data: {},
keys: window.project.token,
successCallback: function (xhr, response) {
window.project.setData2(response);
}
});
var type = document.createElement("input");
type.type = "hidden";
type.name = "TYPE";
type.value = "ASSIGN_TASK";
var uid = document.createElement("input");
uid.type = "hidden";
uid.name = "UID";
uid.value = dyn_uid;
var position = document.createElement("input");
position.type = "hidden";
position.name = "POSITION";
position.value = "10000";
var action = document.createElement("input");
action.type = "hidden";
action.name = "ACTION";
action.value = "ASSIGN";
var dynaformname = document.createElement("input");
dynaformname.type = "hidden";
dynaformname.name = "__DynaformName__";
dynaformname.value = __DynaformName__;
var appuid = document.createElement("input");
appuid.type = "hidden";
appuid.name = "APP_UID";
appuid.value = app_uid;
var form = document.getElementsByTagName("form")[0];
form.action = "cases_SaveData?UID=" + dyn_uid + "&APP_UID=" + app_uid;
form.method = "post";
form.appendChild(type);

View File

@@ -385,7 +385,6 @@ if ($actionAjax == 'dynaformChangeLogViewHistory') {
G::LoadClass('pmDynaform');
$a = new pmDynaform($_GET['DYN_UID'], $Fields['APP_DATA']);
if ($a->isResponsive()) {
$a->mergeValues();
$a->printView((!isset($_SESSION["PM_RUN_OUTSIDE_MAIN_APP"])) ? "true" : "false", $_SESSION['APPLICATION']);
} else {
$G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_POST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view');
@@ -475,7 +474,6 @@ if ($actionAjax == 'historyDynaformGridPreview') {
G::LoadClass('pmDynaform');
$a = new pmDynaform($_GET['DYN_UID'], $Fields['APP_DATA']);
if ($a->isResponsive()) {
$a->mergeValues();
$a->printView((!isset($_SESSION["PM_RUN_OUTSIDE_MAIN_APP"])) ? "true" : "false", $_SESSION['APPLICATION']);
} else {
$G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_POST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view');

View File

@@ -264,7 +264,6 @@ try {
G::LoadClass('pmDynaform');
$a = new pmDynaform($_GET['UID'], $Fields['APP_DATA']);
if ($a->isResponsive()) {
$a->mergeValues();
$a->printEdit((!isset($_SESSION["PM_RUN_OUTSIDE_MAIN_APP"])) ? "true" : "false", $_SESSION['APPLICATION'], $array);
} else {
$G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_GET['UID'], '', $Fields['APP_DATA'], 'cases_SaveData?UID=' . $_GET['UID'] . '&APP_UID=' . $_SESSION['APPLICATION'], '', (strtolower($oStep->getStepMode()) != 'edit' ? strtolower($oStep->getStepMode()) : ''));

View File

@@ -1439,7 +1439,7 @@ class Cases
$fields = $case->loadCase($app_uid);
$_POST['form'] = $app_data;
if (!is_null($dyn_uid)) {
if (!is_null($dyn_uid) && $dyn_uid != '') {
$oDynaform = \DynaformPeer::retrieveByPK($dyn_uid);
if ($oDynaform->getDynVersion() < 2) {

View File

@@ -24,10 +24,29 @@
var dyn_uid = '{DYN_UID}';
var __DynaformName__ = '{DYNAFORMNAME}';
var app_uid = '{APP_UID}';
var prj_uid = '{PRJ_UID}';
var workspace = '{WORKSPACE}';
var credentials = {credentials};
$(window).load(function () {
var data = jsondata;
window.dynaform = new PMDynaform.core.Project({
data: data
window.project = new PMDynaform.core.Project({
data: data,
keys: {
server: location.host,
projectId: prj_uid,
workspace: workspace
},
token: credentials,
submitRest: false
});
new PMDynaform.core.Proxy({
url: "http://" + window.project.keys.server + "/" + window.project.keys.apiName + "/" + window.project.keys.apiVersion + "/" + window.project.keys.workspace + "/cases/" + app_uid + "/variables",
method: 'GET',
data: {},
keys: window.project.token,
successCallback: function (xhr, response) {
window.project.setData2(response);
}
});
$(document).find('form').submit(function (e) {
e.preventDefault();

View File

@@ -1,3 +1,4 @@
<!DOCTYPE html>
<head>
<!-- translations -->
<script type="text/javascript" src="{$translationMafe}"></script>