FSN#40183 Kopie record maken via scaffolding
svn path=/Website/trunk/; revision=33472
This commit is contained in:
@@ -29,6 +29,9 @@ function scaffolding_edit(model, scf_params)
|
||||
|
||||
if (scf_params.incsetting)
|
||||
transit += "&" + scf_params.incsetting.joinfield + "=" + getQParamInt(scf_params.incsetting.joinfield);
|
||||
var cloning = getQParamInt( "scf_clone", 0 ) == 1;
|
||||
if (cloning)
|
||||
transit += "&scf_clone=1";
|
||||
|
||||
var key = getQParamInt("id", -1);
|
||||
var multi = getQParamInt("scf_multi", 0) == 1;
|
||||
@@ -64,6 +67,10 @@ function scaffolding_edit(model, scf_params)
|
||||
for (var fld in model.fields)
|
||||
{
|
||||
var field = model.fields[fld];
|
||||
|
||||
if (cloning && (field.clone === false || fld == "id"))
|
||||
xxx_data[fld] = field.defaultvalue;
|
||||
|
||||
if (field.uniquewith)
|
||||
{
|
||||
if (!xxx_data.name && !(fld in filter))
|
||||
@@ -194,7 +201,7 @@ function scaffolding_edit(model, scf_params)
|
||||
FcltMgr.closeDetail(window, { cancel: true } );
|
||||
}
|
||||
|
||||
<% if (!multi) { %>
|
||||
<% if (!multi && modal && key > 0) { %>
|
||||
function scf_history()
|
||||
{
|
||||
<%
|
||||
|
||||
@@ -17,6 +17,12 @@ function scaffolding_save(model, scf_params)
|
||||
protectRequest.validateToken();
|
||||
var key = getQParamInt( "id" );
|
||||
var multi = getFParamInt( "scf_multi", 0 ) == 1;
|
||||
var cloning = getQParamInt( "scf_clone", 0 ) == 1;
|
||||
if (cloning)
|
||||
{
|
||||
var clone_key = key;
|
||||
key = -1;
|
||||
}
|
||||
|
||||
var formfields = [];
|
||||
for (var fld in model.fields)
|
||||
@@ -36,6 +42,34 @@ function scaffolding_save(model, scf_params)
|
||||
params.multiadd = scf_params.incsetting && scf_params.incsetting.multiadd;
|
||||
|
||||
var jsondata = api2.form2JSONdata(model, params, formfields);
|
||||
|
||||
if (cloning)
|
||||
{
|
||||
// Bepaal de mee te nemen includes van de oude data
|
||||
var incs = [];
|
||||
for (var inc in model.includes)
|
||||
{
|
||||
var include = model.includes[inc];
|
||||
if (include.enable_update)
|
||||
incs.push(inc)
|
||||
}
|
||||
var olddata = api2.GET(model, clone_key, { include: incs } );
|
||||
for (var fld in model.fields)
|
||||
{
|
||||
var field = model.fields[fld];
|
||||
if (field.insertonly)
|
||||
jsondata[fld] = olddata[fld];
|
||||
}
|
||||
for (var inc in model.includes)
|
||||
{
|
||||
var include = model.includes[inc];
|
||||
if (include.enable_update)
|
||||
jsondata[inc] = olddata[inc];
|
||||
}
|
||||
__Log("Cloning data:");
|
||||
__Log(jsondata);
|
||||
}
|
||||
|
||||
params.properties = { extraserie: false,
|
||||
nameprefix: "k"
|
||||
};
|
||||
|
||||
@@ -157,6 +157,12 @@ function scaffolding_show(model, scf_params)
|
||||
}
|
||||
}
|
||||
|
||||
function scf_clone()
|
||||
{
|
||||
var url = "<%=scf_params.this_path%>?mode=wrap&scf_clone=1&id=<%=key%><%=transit%>"
|
||||
FcltMgr.openDetail(url);
|
||||
}
|
||||
|
||||
function xxx_delete()
|
||||
{
|
||||
FcltMgr.confirm('<%=safe.jsstring(L("lcl_scf_confirm_delete").format(model.record_title, xxx_data.name || xxx_data.id))%>',
|
||||
@@ -213,6 +219,9 @@ function scaffolding_show(model, scf_params)
|
||||
if (user.has("WEB_FACFAC") && model["REST_POST"])
|
||||
buttons.push({ title: L("lcl_scf_export"), action: "scf_export()", icon: "fa-download" });
|
||||
|
||||
if (key > 0 && model["REST_POST"])
|
||||
buttons.push({ title: L("lcl_scf_clone"), action: "scf_clone()", icon: "copy.png" });
|
||||
|
||||
if (key > 0 && cnt > 0)
|
||||
{
|
||||
buttons.push({title: L("lcl_history") + " ({0})".format(cnt), action:"scf_history()", icon: "fa-history", id: "btn_scf_history" });
|
||||
|
||||
@@ -20,6 +20,7 @@ function scaffolding_wrap(model, scf_params)
|
||||
var transit = scf_transit2url(scf_params);
|
||||
|
||||
var key = getQParam("id", -1);
|
||||
var cloning = getQParamInt( "scf_clone", 0 ) == 1;
|
||||
|
||||
FCLTHeader.Requires({plugins:["jQuery", "suggest"], js: ["jquery-ui.js"]})
|
||||
|
||||
@@ -32,12 +33,12 @@ function scaffolding_wrap(model, scf_params)
|
||||
<script type="text/javascript" >
|
||||
<% if (key > 0)
|
||||
{ %>
|
||||
FcltMgr.setTitle("<%=safe.jsstring(scf_title)%>", {hot: false});
|
||||
FcltMgr.setTitle("<%=(cloning?L("lcl_scf_clonettl") + " ":"") + safe.jsstring(scf_title)%>", {hot: false});
|
||||
<% } %>
|
||||
|
||||
function scfClose(params)
|
||||
{
|
||||
<% if (key < 0)
|
||||
<% if (key < 0 || cloning)
|
||||
{ %>
|
||||
if (params.cancel)
|
||||
{
|
||||
@@ -58,15 +59,17 @@ function scaffolding_wrap(model, scf_params)
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<% if (key < 0)
|
||||
<% if (key < 0 || cloning)
|
||||
var page = scf_params.this_fullpath + "?mode=edit" + transit; // Maak een nieuw
|
||||
else
|
||||
var page = scf_params.this_fullpath + "?mode=show" + transit;
|
||||
page += "&id=" + key;
|
||||
if (cloning)
|
||||
page += "&scf_clone=1"
|
||||
|
||||
IFRAMER("scfFrame", page, { FcltClose: "scfClose" } );
|
||||
|
||||
if (key > 0)
|
||||
if (key > 0 && !cloning)
|
||||
{
|
||||
if (!scf_params.wrap.no_default_frames)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user