mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
N°2847 Add backend for new entry form for activity panel
This commit is contained in:
@@ -36,7 +36,7 @@ $ibo-activity-panel--body--add-caselog-entry--toggler--icon--line-height: 33px !
|
|||||||
|
|
||||||
.ibo-activity-panel--body--add-caselog-entry--toggler{
|
.ibo-activity-panel--body--add-caselog-entry--toggler{
|
||||||
@extend %ibo-baseline-centered-content;
|
@extend %ibo-baseline-centered-content;
|
||||||
float: right;
|
position: absolute;
|
||||||
right: $ibo-activity-panel--body--add-caselog-entry--toggler--right;
|
right: $ibo-activity-panel--body--add-caselog-entry--toggler--right;
|
||||||
margin-top: $ibo-activity-panel--body--add-caselog-entry--toggler--margin-top;
|
margin-top: $ibo-activity-panel--body--add-caselog-entry--toggler--margin-top;
|
||||||
|
|
||||||
@@ -58,4 +58,7 @@ $ibo-activity-panel--body--add-caselog-entry--toggler--icon--line-height: 33px !
|
|||||||
&:hover {
|
&:hover {
|
||||||
color: $ibo-activity-panel--body--add-caselog-entry--toggler--color;
|
color: $ibo-activity-panel--body--add-caselog-entry--toggler--color;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.ibo-activity-new-entry-form--action-buttons--right-actions > .ibo-popover-menu{
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
@@ -43,11 +43,12 @@ $(function() {
|
|||||||
right_actions: '[data-role="ibo-activity-new-entry-form--action-buttons--right-actions"]',
|
right_actions: '[data-role="ibo-activity-new-entry-form--action-buttons--right-actions"]',
|
||||||
caselog_picker: '[data-role="ibo-popover-menu"]',
|
caselog_picker: '[data-role="ibo-popover-menu"]',
|
||||||
},
|
},
|
||||||
|
|
||||||
// the constructor
|
// the constructor
|
||||||
_create: function () {
|
_create: function () {
|
||||||
let me = this;
|
let me = this;
|
||||||
me._HideNewEntryForm();
|
me._HideNewEntryForm();
|
||||||
|
$(this.element).find(this.js_selectors.caselog_picker).popover_menu({toggler: this.js_selectors.right_actions});
|
||||||
$(this.js_selectors.toggler).on('click', function(oEvent){
|
$(this.js_selectors.toggler).on('click', function(oEvent){
|
||||||
me._ShowNewEntryForm();
|
me._ShowNewEntryForm();
|
||||||
});
|
});
|
||||||
@@ -67,7 +68,7 @@ $(function() {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$(this).children(me.js_selectors.caselog_picker).show();
|
$(this).children(me.js_selectors.caselog_picker).popover_menu('openPopup');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(this.js_selectors.right_actions).on('cancel', function(oEvent){
|
$(this.js_selectors.right_actions).on('cancel', function(oEvent){
|
||||||
@@ -84,7 +85,20 @@ $(function() {
|
|||||||
},
|
},
|
||||||
_SubmitNewEntryToCaselog: function(sData, sCaselog)
|
_SubmitNewEntryToCaselog: function(sData, sCaselog)
|
||||||
{
|
{
|
||||||
alert('Submited '+ sData +' to ' + sCaselog + ' caselog');
|
const me = this;
|
||||||
|
let oParams = {
|
||||||
|
'operation' : 'add_caselog_entry',
|
||||||
|
'class' : 'UserRequest',
|
||||||
|
'id' : '1',
|
||||||
|
'caselog_new_entry': sData,
|
||||||
|
'caselog_attcode' : sCaselog,
|
||||||
|
'caselog_rank' : $(me.js_selectors.panel).activity_panel('GetCaseLogRank', sCaselog),
|
||||||
|
}
|
||||||
|
//TODO 2.8.0 Handle errors
|
||||||
|
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(sNewEntry){
|
||||||
|
$(me.js_selectors.panel).activity_panel('AddEntry', sNewEntry, 'caselog:' + sCaselog)
|
||||||
|
me._HideNewEntryForm();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -275,6 +275,56 @@ $(function()
|
|||||||
this.element.find(this.js_selectors.entry+'[data-entry-type="'+sEntryType+'"]').addClass(this.css_classes.is_hidden);
|
this.element.find(this.js_selectors.entry+'[data-entry-type="'+sEntryType+'"]').addClass(this.css_classes.is_hidden);
|
||||||
this._UpdateEntryGroupsVisibility();
|
this._UpdateEntryGroupsVisibility();
|
||||||
},
|
},
|
||||||
|
_GetNewEntryGroup: function()
|
||||||
|
{
|
||||||
|
let AjaxNewEntryGroupDeferred = jQuery.Deferred();
|
||||||
|
const me = this;
|
||||||
|
var oParams = {
|
||||||
|
'operation' : 'new_entry_group',
|
||||||
|
'caselog_new_entry': sData,
|
||||||
|
'caselog_attcode' : sCaselog,
|
||||||
|
}
|
||||||
|
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data){
|
||||||
|
AjaxNewEntryGroupDeferred.resolve(data);
|
||||||
|
});
|
||||||
|
return AjaxNewEntryGroupDeferred.promise();
|
||||||
|
},
|
||||||
|
_AddEntry: function(sEntry, sOrigin)
|
||||||
|
{
|
||||||
|
let aEntryGroup = this.element.find(this.js_selectors.entry_group)
|
||||||
|
let sAuthorLogin = $(sEntry).attr('data-entry-author-login');
|
||||||
|
if (aEntryGroup.length > 0 && $(aEntryGroup[0]).attr('data-entry-group-author-login') === sAuthorLogin && $(aEntryGroup[0]).attr('data-entry-group-origin') === sOrigin)
|
||||||
|
{
|
||||||
|
$(aEntryGroup[0]).prepend(sEntry);
|
||||||
|
this._ReformatDateTimes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO 2.8.0 Create a new entry group
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
AddEntry: function(sEntry, sOrigin)
|
||||||
|
{
|
||||||
|
this._AddEntry(sEntry, sOrigin);
|
||||||
|
},
|
||||||
|
_GetCaseLogRank: function(sCaseLog)
|
||||||
|
{
|
||||||
|
let iIdx = 0;
|
||||||
|
let oCaselogTab = this.element.find(this.js_selectors.tab +
|
||||||
|
'[data-tab-type="caselog"]' +
|
||||||
|
'[data-caselog-attribute-code="'+ sCaseLog +'"]'
|
||||||
|
);
|
||||||
|
if(oCaselogTab.length > 0 && oCaselogTab.attr('data-caselog-rank'))
|
||||||
|
{
|
||||||
|
iIdx = parseInt(oCaselogTab.attr('data-caselog-rank'));
|
||||||
|
}
|
||||||
|
return iIdx;
|
||||||
|
},
|
||||||
|
GetCaseLogRank: function(sCaseLog)
|
||||||
|
{
|
||||||
|
return this._GetCaseLogRank(sCaseLog);
|
||||||
|
},
|
||||||
_UpdateEntryGroupsVisibility: function()
|
_UpdateEntryGroupsVisibility: function()
|
||||||
{
|
{
|
||||||
const me = this;
|
const me = this;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Combodo\iTop\Application\UI\Layout\ActivityPanel\ActivityEntry\ActivityEntryFactory;
|
||||||
use Combodo\iTop\Controller\AjaxRenderController;
|
use Combodo\iTop\Controller\AjaxRenderController;
|
||||||
use Combodo\iTop\Renderer\Console\ConsoleFormRenderer;
|
use Combodo\iTop\Renderer\Console\ConsoleFormRenderer;
|
||||||
|
|
||||||
@@ -2782,6 +2783,28 @@ EOF
|
|||||||
}
|
}
|
||||||
$oPage->add(json_encode($aResult));
|
$oPage->add(json_encode($aResult));
|
||||||
break;
|
break;
|
||||||
|
case 'add_caselog_entry':
|
||||||
|
// TODO 2.8.0: Handle errors & rights
|
||||||
|
$sClass = utils::ReadPostedParam('class', '', 'class');
|
||||||
|
$sClassLabel = MetaModel::GetName($sClass);
|
||||||
|
$id = utils::ReadPostedParam('id', '');
|
||||||
|
// TODO 2.8.0 Handle transactions token
|
||||||
|
$sTransactionId = utils::ReadPostedParam('transaction_id', '', 'transaction_id');
|
||||||
|
$sCaseLogAttCode = utils::ReadPostedParam('caselog_attcode', '');
|
||||||
|
$sCaseLogNewEntry = utils::ReadPostedParam('caselog_new_entry', '', 'raw');
|
||||||
|
$iCaseLogRank = utils::ReadPostedParam('caselog_rank', 0, 'integer');
|
||||||
|
if($id !== 0 && MetaModel::IsValidClass($sClass))
|
||||||
|
{
|
||||||
|
$oObj = MetaModel::GetObject($sClass, $id);
|
||||||
|
$oObj->Set($sCaseLogAttCode, $sCaseLogNewEntry);
|
||||||
|
$oObj->DBWrite();
|
||||||
|
}
|
||||||
|
$oNewEntry = ActivityEntryFactory::MakeFromCaseLogEntryArray($sCaseLogAttCode, $oObj->Get($sCaseLogAttCode)->GetAsArray()[0]);
|
||||||
|
$oNewEntry->SetCaseLogRank($iCaseLogRank);
|
||||||
|
$oPage->AddUiBlock($oNewEntry);
|
||||||
|
break;
|
||||||
|
case 'new_entry_group':
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$oPage->p("Invalid query.");
|
$oPage->p("Invalid query.");
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ class ActivityNewEntryForm extends UIContentBlock
|
|||||||
{
|
{
|
||||||
$aSubBlocks[$oFormActionButton->GetId()] = $oFormActionButton;
|
$aSubBlocks[$oFormActionButton->GetId()] = $oFormActionButton;
|
||||||
}
|
}
|
||||||
|
$oCaseLogSelectionPopOverMenu = $this->GetCaseLogSelectionPopOverMenu();
|
||||||
|
$aSubBlocks[$oCaseLogSelectionPopOverMenu->GetId()] = $oCaseLogSelectionPopOverMenu;
|
||||||
|
|
||||||
return $aSubBlocks;
|
return $aSubBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="ibo-activity-panel--header">
|
<div class="ibo-activity-panel--header">
|
||||||
<div class="ibo-activity-panel--tabs">
|
<div class="ibo-activity-panel--tabs">
|
||||||
{% for sCaseLogAttCode, aCaseLogData in oUIBlock.GetCaseLogTabs() %}
|
{% for sCaseLogAttCode, aCaseLogData in oUIBlock.GetCaseLogTabs() %}
|
||||||
<div class="ibo-activity-panel--tab ibo-activity-panel--tab-for-caselog ibo-activity-panel--tab-for-caselog-{{ loop.index }}" data-role="ibo-activity-panel--tab" data-tab-type="caselog" data-caselog-attribute-code="{{ sCaseLogAttCode }}">
|
<div class="ibo-activity-panel--tab ibo-activity-panel--tab-for-caselog ibo-activity-panel--tab-for-caselog-{{ loop.index }}" data-role="ibo-activity-panel--tab" data-tab-type="caselog" data-caselog-attribute-code="{{ sCaseLogAttCode }}" data-caselog-rank="{{ loop.index }}">
|
||||||
<a href="#" class="ibo-activity-panel--tab-title" data-role="ibo-activity-panel--tab-title">
|
<a href="#" class="ibo-activity-panel--tab-title" data-role="ibo-activity-panel--tab-title">
|
||||||
<span class="ibo-activity-panel--tab-decoration"></span>
|
<span class="ibo-activity-panel--tab-decoration"></span>
|
||||||
<span class="ibo-activity-panel--tab-text">{{ aCaseLogData.title }}</span>
|
<span class="ibo-activity-panel--tab-text">{{ aCaseLogData.title }}</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user