Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

48659 Optional writing of tasks in onOffice enterprise with plugin forms & fields. #826

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dd5bf49
48659 update option create task for form
yeneastgate May 31, 2024
32d7936
48659 add required field
yeneastgate May 31, 2024
1538df7
48659 refactor code
yeneastgate May 31, 2024
0004606
48659 update unit test
yeneastgate Jun 3, 2024
03d3f60
48659 refactor code
yeneastgate Jun 3, 2024
1e12100
48659 fix conflict
yeneastgate Jun 6, 2024
05191fd
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
yeneastgate Jun 17, 2024
c7a5657
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
yeneastgate Jun 19, 2024
4228d43
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
yeneastgate Jun 19, 2024
7840271
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
dai-eastgate Aug 30, 2024
77f4f7f
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
yeneastgate Sep 12, 2024
70068f6
48659 update type task callback
yeneastgate Sep 12, 2024
e42ee1a
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
dai-eastgate Sep 25, 2024
bb61844
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
dai-eastgate Sep 30, 2024
d9d84b0
48659 update unit test
dai-eastgate Sep 30, 2024
57b0af5
48659 merge master
dai-eastgate Oct 21, 2024
fd6b784
48659 update unit test
dai-eastgate Oct 21, 2024
0eb47a9
48659 update unit test
dai-eastgate Oct 21, 2024
021f908
48659 refactor code
dai-eastgate Oct 21, 2024
9b735b0
48659 merge master
dai-eastgate Oct 22, 2024
06fbbb6
48659 update unit test
dai-eastgate Oct 22, 2024
172f237
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
dai-eastgate Oct 24, 2024
564cd55
update unit test
dai-eastgate Oct 24, 2024
0b100a6
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
dai-eastgate Oct 24, 2024
62cd799
48659 update unit test
dai-eastgate Oct 24, 2024
c1ed63c
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
andernath Oct 25, 2024
b66289e
Merge branch 'master' into 48659-optional-writing-of-tasks-in-onoffic…
andernath Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ body #post-head-content p.wp-clearfix:nth-child(1) {
margin-left: 5px;
}

.oo-poststuff .custom-input-field textarea[name=oopluginformtaskconfig-description],
.oo-poststuff .custom-input-field textarea[name=oopluginformactivityconfig-remark] {
min-height: 100px;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/checkbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions js/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,38 @@ onOffice.checkboxAdmin = function() {
{
element: "input[name^=oopluginformfieldconfig-hiddenfield]",
invert: true
],

// view: create new [task] form
"input[name=oopluginformtaskconfig-enablecreatetask]": [
{
element: "select[name=oopluginformtaskconfig-responsibility]",
invert: false
},
{
element: "select[name=oopluginformtaskconfig-processor]",
invert: false
},
{
element: "select[name=oopluginformtaskconfig-type]",
invert: false,
required: true
},
{
element: "select[name=oopluginformtaskconfig-priority]",
invert: false
},
{
element: "input[name=oopluginformtaskconfig-subject]",
invert: false
},
{
element: "textarea[name=oopluginformtaskconfig-description]",
invert: false
},
{
element: "select[name=oopluginformtaskconfig-status]",
invert: false
},
],

Expand Down Expand Up @@ -100,6 +132,7 @@ onOffice.checkboxAdmin.prototype.changeCbStatus = function(topElement) {
var receiver = receivers[i];
var receiverElement = mainElement.parent().parent().find(receiver.element);
var invert = receiver.invert;
let required = receiver.required;

if (receiverElement.length) {
if (mainElement.prop('checked')) {
Expand All @@ -110,13 +143,19 @@ onOffice.checkboxAdmin.prototype.changeCbStatus = function(topElement) {
receiverElement.prop('disabled', 'disabled');
receiverElement.removeAttr('checked');
}
if (required) {
receiverElement.attr('required', 'required');
}
} else {
if (!invert) {
receiverElement.prop('disabled', 'disabled');
receiverElement.removeAttr('checked');
} else {
receiverElement.removeAttr('disabled');
}
if (required) {
receiverElement.attr('required', 'required');
}
}
}
}
Expand Down
88 changes: 88 additions & 0 deletions plugin/DataFormConfiguration/DataFormConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ class DataFormConfiguration
/** @var string */
private $_advisorylevel = '';

/** @var bool */
private $_enableCreateTask = false;

/** @var string */
private $_taskResponsibility = '';

/** @var string */
private $_taskProcessor = '';

/** @var int */
private $_taskType = 0;

/** @var string */
private $_taskSubject = '';

/** @var string */
private $_taskDescription = '';

/** @var int */
private $_taskStatus = 0;

/** @var int */
private $_taskPriority = 0;

/**
*
* Override to set default fields for new, empty forms
Expand Down Expand Up @@ -327,4 +351,68 @@ public function getAdvisorylevel(): string
/** @param string $advisorylevel */
public function setAdvisorylevel(string $advisorylevel)
{ $this->_advisorylevel = $advisorylevel; }

/** @return bool */
public function getEnableCreateTask(): bool
{ return $this->_enableCreateTask; }

/** @param bool $enableCreateTask */
public function setEnableCreateTask(bool $enableCreateTask)
{ $this->_enableCreateTask = $enableCreateTask; }

/** @return string */
public function getTaskResponsibility(): string
{ return $this->_taskResponsibility; }

/** @param string $taskResponsibility */
public function setTaskResponsibility(string $taskResponsibility)
{ $this->_taskResponsibility = $taskResponsibility; }

/** @return string */
public function getTaskProcessor(): string
{ return $this->_taskProcessor; }

/** @param string $taskProcessor */
public function setTaskProcessor(string $taskProcessor)
{ $this->_taskProcessor = $taskProcessor; }

/** @return int */
public function getTaskType(): int
{ return $this->_taskType; }

/** @param int $taskType */
public function setTaskType(int $taskType)
{ $this->_taskType = $taskType; }

/** @return int */
public function getTaskPriority(): int
{ return $this->_taskPriority; }

/** @param int $taskPriority */
public function setTaskPriority(int $taskPriority)
{ $this->_taskPriority = $taskPriority; }

/** @return string */
public function getTaskSubject(): string
{ return $this->_taskSubject; }

/** @param string $taskSubject */
public function setTaskSubject(string $taskSubject)
{ $this->_taskSubject = $taskSubject; }

/** @return string */
public function getTaskDescription(): string
{ return $this->_taskDescription; }

/** @param string $taskDescription */
public function setTaskDescription(string $taskDescription)
{ $this->_taskDescription = $taskDescription; }

/** @return int */
public function getTaskStatus(): int
{ return $this->_taskStatus; }

/** @param int $taskStatus */
public function setTaskStatus(int $taskStatus)
{ $this->_taskStatus = $taskStatus; }
}
23 changes: 23 additions & 0 deletions plugin/DataFormConfiguration/DataFormConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ private function createByRow(array $row)
if ($this->_type !== Form::TYPE_APPLICANT_SEARCH){
$rowActivityConfig = $this->_pRecordManagerRead->readActivityConfigByFormId($formId);
$this->configureActivity($pConfig, $rowActivityConfig);
$rowTaskConfig = $this->_pRecordManagerRead->readFormTaskConfigByFormId($formId);
$this->configureTask($pConfig, $rowTaskConfig);
}

foreach ($rowFields as $fieldRow) {
Expand Down Expand Up @@ -291,6 +293,27 @@ private function configureGeoFields(array $result): array
return $result;
}

/**
* @param DataFormConfiguration\DataFormConfiguration $pFormConfiguration
* @param array|null $row
* @return void
*/
private function configureTask(DataFormConfiguration\DataFormConfiguration $pFormConfiguration, array $row = null)
{
if (empty($row)) {
return;
}

$pFormConfiguration->setEnableCreateTask((bool)$row['enable_create_task']);
$pFormConfiguration->setTaskResponsibility($row['responsibility']);
$pFormConfiguration->setTaskProcessor($row['processor']);
$pFormConfiguration->setTaskType($row['type']);
$pFormConfiguration->setTaskPriority($row['priority']);
$pFormConfiguration->setTaskSubject($row['subject']);
$pFormConfiguration->setTaskDescription($row['description']);
$pFormConfiguration->setTaskStatus($row['status']);
}


/**
*
Expand Down
16 changes: 14 additions & 2 deletions plugin/Field/Collection/FieldLoaderSupervisorValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ class FieldLoaderSupervisorValues implements FieldLoader
/** @var SDKWrapper */
private $_pSDKWrapper;

public function __construct(SDKWrapper $_pSDKWrapper)
/** @var bool */
private $_isReturnValueForUserNameElements;

/**
* @param SDKWrapper $_pSDKWrapper
* @param bool $isReturnValueForUserNameElements
*/
public function __construct(SDKWrapper $_pSDKWrapper, bool $isReturnValueForUserNameElements = false)
{
$this->_pSDKWrapper = $_pSDKWrapper;
$this->_isReturnValueForUserNameElements = $isReturnValueForUserNameElements;
}

/**
Expand Down Expand Up @@ -109,7 +117,11 @@ private function getFullNameSupervisor(): array
}
}

$fullNameSupervisor[$value['elements']['id']] = $fullName;
if ($this->_isReturnValueForUserNameElements) {
$fullNameSupervisor[$value['elements']['username']] = $fullName;
} else {
$fullNameSupervisor[$value['elements']['id']] = $fullName;
}
}

return $fullNameSupervisor;
Expand Down
40 changes: 39 additions & 1 deletion plugin/Form/FormAddressCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
use onOffice\WPlugin\API\APIClientActionGeneric;
use onOffice\WPlugin\API\ApiClientException;
use onOffice\WPlugin\Cache\CacheHandler;
use onOffice\WPlugin\DataFormConfiguration\DataFormConfiguration;
use onOffice\WPlugin\Field\Collection\FieldsCollectionBuilderShort;
use onOffice\WPlugin\Field\UnknownFieldException;
use onOffice\WPlugin\FormData;
use onOffice\WPlugin\SDKWrapper;
use onOffice\WPlugin\Types\FieldsCollection;
use onOffice\WPlugin\Types\FieldTypes;
use onOffice\WPlugin\Language;
use onOffice\WPlugin\DataFormConfiguration\DataFormConfiguration;

/**
*
Expand Down Expand Up @@ -409,6 +409,8 @@ private function getAddressDataForReadAddressApiCall(FormData $pFormData): array
* @param DataFormConfiguration $pFormConfig
* @param int $addressId
* @param int|null $estateId
*
* @return void
*/
public function createAgentsLog(DataFormConfiguration $pFormConfig, int $addressId, int $estateId = null)
{
Expand All @@ -434,4 +436,40 @@ public function createAgentsLog(DataFormConfiguration $pFormConfig, int $address
$pApiClientAction->setParameters($requestParams);
$pApiClientAction->addRequestToQueue()->sendRequests();
}

/**
* @param DataFormConfiguration $pFormConfig
* @param int $addressId
* @param int|null $estateId
*
* @return void
*/
public function createTask(DataFormConfiguration $pFormConfig, int $addressId, int $estateId = null)
{
if (empty($pFormConfig->getTaskType()) || empty($pFormConfig->getTaskStatus())) {
return;
}

$requestParams = [
'data' => [
'Prio' => $pFormConfig->getTaskPriority(),
'Verantwortung' => $pFormConfig->getTaskResponsibility(),
'Art' => $pFormConfig->getTaskType(),
'Status' => $pFormConfig->getTaskStatus(),
'Bearbeiter' => $pFormConfig->getTaskProcessor(),
'Betreff' => $pFormConfig->getTaskSubject(),
'Aufgabe' => $pFormConfig->getTaskDescription()
],
'relatedAddressId' => $addressId,
];

if (!empty($estateId)) {
$requestParams['relatedEstateId'] = $estateId;
}

$pApiClientAction = new APIClientActionGeneric
($this->_pSDKWrapper, onOfficeSDK::ACTION_ID_CREATE, 'task');
$pApiClientAction->setParameters($requestParams);
$pApiClientAction->addRequestToQueue()->sendRequests();
}
}
5 changes: 5 additions & 0 deletions plugin/FormPostContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private function createAddress(FormData $pFormData)
$checkDuplicate = $pFormConfig->getCheckDuplicateOnCreateAddress();
$writeActivity = $pFormConfig->getWriteActivity();
$contactType = $pFormConfig->getContactType();
$enableCreateTask = $pFormConfig->getEnableCreateTask();
$pWPQuery = $this->_pFormPostContactConfiguration->getWPQueryWrapper()->getWPQuery();
$estateId = $pWPQuery->get('estate_id', null);
$latestAddressIdOnEnterPrise = null;
Expand All @@ -161,6 +162,10 @@ private function createAddress(FormData $pFormData)
$this->_pFormPostContactConfiguration->getFormAddressCreator()->createAgentsLog($pFormConfig, $addressId, $estateId);
}

if ($enableCreateTask) {
$this->_pFormPostContactConfiguration->getFormAddressCreator()->createTask($pFormConfig, $addressId, $estateId);
}

if (!$this->_pFormPostContactConfiguration->getNewsletterAccepted()) {
// No subscription for newsletter, which is ok
return;
Expand Down
4 changes: 4 additions & 0 deletions plugin/FormPostInterest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$estateId = $pWPQuery->get('estate_id', null);
$writeActivity = $pFormConfiguration->getWriteActivity();
$latestAddressIdOnEnterPrise = null;
$enableCreateTask = $pFormConfiguration->getEnableCreateTask();
if ($checkDuplicate) {
$latestAddressIdOnEnterPrise = $this->_pFormPostInterestConfiguration->getFormAddressCreator()->getLatestAddressIdInOnOfficeEnterprise();
}
Expand All @@ -103,6 +104,9 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$this->_pFormPostInterestConfiguration->getFormAddressCreator()->createAgentsLog($pFormConfiguration, $addressId, null);
}
$this->setNewsletter( $addressId );
if ($enableCreateTask) {
$this->_pFormPostInterestConfiguration->getFormAddressCreator()->createTask($pFormConfiguration, $addressId, $estateId);
}
}
} finally {
if ( $recipient != null ) {
Expand Down
4 changes: 4 additions & 0 deletions plugin/FormPostOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
if ( $pDataFormConfiguration->getCreateOwner() ) {
$checkDuplicate = $pDataFormConfiguration->getCheckDuplicateOnCreateAddress();
$contactType = $pDataFormConfiguration->getContactType();
$enableCreateTask = $pDataFormConfiguration->getEnableCreateTask();
$pWPQuery = $this->_pFormPostOwnerConfiguration->getWPQueryWrapper()->getWPQuery();
$estateId = $pWPQuery->get('estate_id', null);
$writeActivity = $pDataFormConfiguration->getWriteActivity();
Expand All @@ -122,6 +123,9 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$this->_pFormPostOwnerConfiguration->getFormAddressCreator()->createAgentsLog($pDataFormConfiguration, $addressId, $estateId);
}
$this->setNewsletter( $addressId );
if ($enableCreateTask) {
$this->_pFormPostOwnerConfiguration->getFormAddressCreator()->createTask($pDataFormConfiguration, $addressId, $estateId);
}
}
} finally {
if ( null != $recipient ) {
Expand Down
Loading
Loading