added rfe #w9099: Thingy field-copy function
This commit is contained in:
parent
858c9033b9
commit
1527ac43e8
2 changed files with 58 additions and 25 deletions
|
|
@ -643,7 +643,10 @@ sub getEditFieldForm {
|
|||
}
|
||||
|
||||
my $dialogPrefix;
|
||||
if ($fieldId eq "new"){
|
||||
if ($field->{oldFieldId}){
|
||||
$dialogPrefix = "edit_".$field->{oldFieldId}."_Dialog_copy";
|
||||
}
|
||||
elsif($fieldId eq "new"){
|
||||
$dialogPrefix = "addDialog";
|
||||
}
|
||||
else{
|
||||
|
|
@ -1727,7 +1730,10 @@ sub www_editThing {
|
|||
." <td style='width:100px;' valign='top' class='formDescription'>".$field->{label}."</td>\n"
|
||||
." <td style='width:370px;'>".$formElement."</td>\n"
|
||||
." <td style='width:120px;' valign='top'> <input onClick=\"editListItem('".$self->session->url->page()
|
||||
."?func=editField;fieldId=".$field->{fieldId}.";thingId=".$thingId."','".$field->{fieldId}."')\" value='Edit' type='button'>"
|
||||
."?func=editField;fieldId=".$field->{fieldId}.";thingId=".$thingId."','".$field->{fieldId}."')\" value='Edit' type='button'>"
|
||||
." <input onClick=\"editListItem('".$self->session->url->page()
|
||||
."?func=editField;copy=1;fieldId=".$field->{fieldId}.";thingId=".$thingId."','".$field->{fieldId}
|
||||
."','copy')\" value='Copy' type='button'>"
|
||||
."<input onClick=\"deleteListItem('".$self->session->url->page()."','".$field->{fieldId}."','".$thingId."')\" "
|
||||
."value='Delete' type='button'></td>\n</tr>\n</table>\n</li>\n";
|
||||
|
||||
|
|
@ -2068,12 +2074,19 @@ Returns the html for a pop-up dialog to add or edit a field.
|
|||
|
||||
sub www_editField {
|
||||
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my (%properties,$thingId,$fieldId,$dialogBody);
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
$fieldId = $self->session->form->process("fieldId");
|
||||
$thingId = $self->session->form->process("thingId");
|
||||
%properties = $self->session->db->quickHash("select * from Thingy_fields where thingId=".$self->session->db->quote($thingId)." and fieldId = ".$self->session->db->quote($fieldId)." and assetId = ".$self->session->db->quote($self->get("assetId")));
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
$fieldId = $session->form->process("fieldId");
|
||||
$thingId = $session->form->process("thingId");
|
||||
%properties = $session->db->quickHash("select * from Thingy_fields where thingId=? and fieldId=? and assetId=?",
|
||||
[$thingId,$fieldId,$self->get("assetId")]);
|
||||
if($session->form->process("copy")){
|
||||
$properties{oldFieldId} = $properties{fieldId};
|
||||
$properties{fieldId} = 'new';
|
||||
$properties{label} = $properties{label}.' (copy)';
|
||||
}
|
||||
$dialogBody = $self->getEditFieldForm(\%properties);
|
||||
$self->session->output->print($dialogBody->print);
|
||||
return "chunked";
|
||||
|
|
@ -2157,6 +2170,9 @@ sub www_editFieldSave {
|
|||
."<td style='width:370px;'>".$formElement."</td>\n"
|
||||
."<td style='width:120px;' valign='top'> <input onClick=\"editListItem('".$self->session->url->page()
|
||||
."?func=editField;fieldId=".$newFieldId.";thingId=".$properties{thingId}."','".$newFieldId."')\" value='Edit' type='button'>"
|
||||
." <input onClick=\"editListItem('".$self->session->url->page()
|
||||
."?func=editField;copy=1;fieldId=".$newFieldId.";thingId=".$properties{thingId}."','".$newFieldId
|
||||
."','copy')\" value='Copy' type='button'>"
|
||||
."<input onClick=\"deleteListItem('".$self->session->url->page()."','".$newFieldId
|
||||
."','".$properties{thingId}."')\" value='Delete' type='button'></td>\n</tr>\n</table>";
|
||||
|
||||
|
|
|
|||
|
|
@ -129,15 +129,18 @@ function initOptionalFields(prefix,fieldId) {
|
|||
}
|
||||
}
|
||||
|
||||
function editListItem(url,fieldId) {
|
||||
function editListItem(url,fieldId,copy) {
|
||||
|
||||
var handleGetFormSuccess = function(o){
|
||||
|
||||
var handleSuccess = function(o) {
|
||||
var response = o.responseText;
|
||||
var listItemId = response.slice(0,22);
|
||||
var newInnerHTML = response.slice(22);
|
||||
var label = editFieldDialog.getData().label;
|
||||
|
||||
if(copy){
|
||||
addListItemHTML(listItemId, newInnerHTML,label);
|
||||
}
|
||||
|
||||
var li = new YAHOO.util.Element(listItemId);
|
||||
li.set('innerHTML',newInnerHTML);
|
||||
|
|
@ -159,21 +162,31 @@ function editListItem(url,fieldId) {
|
|||
this.destroy();
|
||||
};
|
||||
function optionalFields() {
|
||||
initOptionalFields("edit_"+fieldId+"_Dialog",fieldId);
|
||||
initOptionalFields(dialogId,fieldId);
|
||||
}
|
||||
editFieldDialog = new YAHOO.widget.Dialog("edit_"+fieldId+"_Dialog", { width:"460px", visible:false, draggable:true, close:true, fixedcenter:true, zIndex:11001, height: "420px",
|
||||
|
||||
var dialogId = "edit_"+fieldId+"_Dialog";
|
||||
if(copy){
|
||||
dialogId = dialogId + '_copy';
|
||||
}
|
||||
|
||||
editFieldDialog = new YAHOO.widget.Dialog(dialogId, { width:"460px", visible:false, draggable:true, close:true, fixedcenter:true, zIndex:11001, height: "420px",
|
||||
autofillheight:false,
|
||||
buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
|
||||
{ text:"Cancel", handler:handleCancel } ]
|
||||
} );
|
||||
|
||||
editFieldDialog.setHeader("Edit Field");
|
||||
|
||||
if(copy){
|
||||
editFieldDialog.setHeader("Copy Field");
|
||||
}else{
|
||||
editFieldDialog.setHeader("Edit Field");
|
||||
}
|
||||
editFieldDialog.setBody(o.responseText);
|
||||
editFieldDialog.render(document.body);
|
||||
editFieldDialog.callback = { success: handleSuccess, failure: handleFailure };
|
||||
editFieldDialog.show();
|
||||
YAHOO.util.Event.onContentReady("edit_"+fieldId+"_Dialog", optionalFields);
|
||||
initHoverHelp("edit_"+fieldId+"_Dialog");
|
||||
YAHOO.util.Event.onContentReady(dialogId, optionalFields);
|
||||
initHoverHelp(dialogId);
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -191,16 +204,8 @@ function editListItem(url,fieldId) {
|
|||
var request = YAHOO.util.Connect.asyncRequest('GET', url, callbackGetForm);
|
||||
}
|
||||
|
||||
|
||||
function initAddFieldDialog() {
|
||||
|
||||
var handleSuccess = function(o) {
|
||||
var response = o.responseText;
|
||||
var listItemId = response.slice(0,22);
|
||||
var newInnerHTML = response.slice(22);
|
||||
var label = addFieldDialog.getData().label;
|
||||
|
||||
var ul1 = new YAHOO.util.Element('ul1');
|
||||
function addListItemHTML(listItemId, newInnerHTML,label){
|
||||
var ul1 = new YAHOO.util.Element('ul1');
|
||||
var li = document.createElement('li');
|
||||
li.id = listItemId;
|
||||
li.className = 'list1';
|
||||
|
|
@ -275,6 +280,18 @@ function initAddFieldDialog() {
|
|||
viewScreenTitle_td.innerHTML = "<input type='checkbox' name='viewScreenTitle_"+listItemId+"' value='1' />";
|
||||
}
|
||||
view_tr.appendChild(viewScreenTitle_td);
|
||||
}
|
||||
|
||||
|
||||
function initAddFieldDialog() {
|
||||
|
||||
var handleSuccess = function(o) {
|
||||
var response = o.responseText;
|
||||
var listItemId = response.slice(0,22);
|
||||
var newInnerHTML = response.slice(22);
|
||||
var label = addFieldDialog.getData().label;
|
||||
addListItemHTML(listItemId, newInnerHTML,label);
|
||||
|
||||
};
|
||||
|
||||
var handleFailure = function(o) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue