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

47946 Optional writing of activities in the agents log with plugin forms & fields. #821

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b22d7bd
47946 update option activity & create agent log
yeneastgate May 24, 2024
3109577
47946 update unit test
yeneastgate May 24, 2024
f6a9fdf
47946 update condition config empty
yeneastgate May 28, 2024
b01d020
47946 fix conflict
yeneastgate Jun 6, 2024
521af61
47946 fix conflict
yeneastgate Jun 6, 2024
e3ce1f8
47946 fix conflig select 2
yeneastgate Jun 6, 2024
cc15079
47946 fix conflig select 2
yeneastgate Jun 6, 2024
af3ac9e
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
yeneastgate Jun 17, 2024
397726a
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
yeneastgate Jun 19, 2024
8a53577
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
yeneastgate Jun 19, 2024
acc0d75
47946 fix conflict
yeneastgate Jul 26, 2024
271c21f
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
fredericalpers Jul 26, 2024
6c5da22
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
yeneastgate Sep 4, 2024
6697e5a
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
fredericalpers Sep 9, 2024
99486c9
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
yeneastgate Sep 10, 2024
c265d1c
47946 update origin contact & advisory level
yeneastgate Sep 16, 2024
a3e4a69
47946 update unit test
yeneastgate Sep 16, 2024
f4eb83f
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
fredericalpers Sep 19, 2024
3213d74
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
dai-eastgate Sep 25, 2024
ec6447a
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
andernath Sep 30, 2024
b425119
Fix merge conflicts
andernath Sep 30, 2024
d9c7833
47946 update unit test
yeneastgate Oct 1, 2024
a422d2c
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
andernath Oct 2, 2024
34e8f6e
Merge branch 'master' into 47946-optional-writing-of-activities-in-th…
yeneastgate Oct 11, 2024
208dffa
47946 update unit test
yeneastgate Oct 11, 2024
d4f7c6f
update ubuntu v.
pospisk Oct 14, 2024
56bdb99
47946 refactor code
yeneastgate Oct 18, 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
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
operating-system: [ubuntu-20.04]
php-versions: ['7.4', '8.0']
name: Unittest on ${{ matrix.operating-system }} with PHP version ${{ matrix.php-versions }}
steps:
Expand Down
18 changes: 18 additions & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ body #post-head-content p.wp-clearfix:nth-child(1) {
color: #999;
}

.select2-dropdown.select2-dropdown--below,
.select2-dropdown.select2-dropdown--above {
margin-top: 0 !important;
}
yeneastgate marked this conversation as resolved.
Show resolved Hide resolved

.oo-poststuff .custom-input-field input[name=oopluginlistviews-countryactive]:checked::before,
.oo-poststuff .custom-input-field input[name=oopluginlistviews-radiusactive]:checked::before {
filter: brightness(0) saturate(100%) invert(35%) sepia(4%) saturate(967%) hue-rotate(170deg) brightness(91%) contrast(94%);
Expand Down Expand Up @@ -679,6 +684,19 @@ body #post-head-content p.wp-clearfix:nth-child(1) {
margin-left: 5px;
}

.oo-poststuff .custom-input-field textarea[name=oopluginformactivityconfig-remark] {
min-height: 100px;
}

.oo-poststuff .select2-container--default.select2-container--disabled .select2-selection--multiple {
background-color: #f6f7f7;
border-color: #dcdcde;
}

.oo-poststuff .select2-container--default .select2-selection--multiple[aria-disabled="true"] .select2-selection__choice {
opacity: 0.5;
}

.oo-search-field {
width: 100%;
float: left;
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.

2 changes: 1 addition & 1 deletion dist/onoffice-custom-select.min.js

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

1 change: 1 addition & 0 deletions dist/onoffice-handle-activity-config.min.js

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

28 changes: 28 additions & 0 deletions js/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,34 @@ onOffice.checkboxAdmin = function() {
invert: true
},
],

// view: create activity form
"input[name=oopluginformactivityconfig-writeactivity]": [
{
element: "select[name=oopluginformactivityconfig-actionkind]",
invert: false
},
{
element: "select[name=oopluginformactivityconfig-actiontype]",
invert: false
},
{
element: "select[name^=oopluginformactivityconfig-characteristic]",
invert: false
},
{
element: "textarea[name=oopluginformactivityconfig-remark]",
invert: false
},
{
element: "select[name^=oopluginformactivityconfig-origincontact]",
invert: false
},
{
element: "select[name^=oopluginformactivityconfig-advisorylevel]",
invert: false
}
]
};
};

Expand Down
5 changes: 5 additions & 0 deletions js/onoffice-custom-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ jQuery(document).ready(function ($) {
$('.custom-multiple-select, .custom-single-select').select2({
width: '100%'
});
if ($('.oo-poststuff .custom-input-field .oo-custom-select2').length > 0) {
yeneastgate marked this conversation as resolved.
Show resolved Hide resolved
$('.oo-poststuff .custom-input-field .oo-custom-select2').select2({
width: '50%'
});
}

if ($adminSelect.length > 0) {
$adminSelect.select2({
Expand Down
32 changes: 32 additions & 0 deletions js/onoffice-handle-activity-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
jQuery(document).ready(function($) {
const actionKindSelect = $('.oo-poststuff select[name="oopluginformactivityconfig-actionkind"]');
const actionTypeSelect = $('.oo-poststuff select[name="oopluginformactivityconfig-actiontype"]');

if (actionTypeSelect.length && actionKindSelect.length) {
const actionTypes = onOffice_loc_settings.action_type;
function populateActionTypes(actionKind) {
if (actionTypeSelect.children('option').length === 0) {
const defaultOption = $('<option></option>').attr('value', '').text(onOffice_loc_settings.default_label_choose);
actionTypeSelect.append(defaultOption);
const selectedActionTypes = actionTypes[actionKind];
if (selectedActionTypes) {
Object.entries(selectedActionTypes).forEach(([value, label]) => {
if (value !== '') {
const option = $('<option></option>').attr('value', value).text(label);
actionTypeSelect.append(option);
}
});
}
}
}

actionKindSelect.on('change', function() {
actionTypeSelect.empty();
const selectedActionKind = $(this).val();
populateActionTypes(selectedActionKind);
});

const initialActionKind = actionKindSelect.val();
populateActionTypes(initialActionKind);
}
});
78 changes: 78 additions & 0 deletions plugin/DataFormConfiguration/DataFormConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ class DataFormConfiguration

/** @var array */
private $_hiddenFields = [];

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

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

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

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

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

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

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

/**
*
* Override to set default fields for new, empty forms
Expand Down Expand Up @@ -249,4 +271,60 @@ public function getRecipientByUserSelection(): string {

return $this->_recipient;
}

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

/** @param bool $writeActivity */
public function setWriteActivity(bool $writeActivity)
{ $this->_writeActivity = $writeActivity; }

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

/** @param string $actionKind */
public function setActionKind(string $actionKind)
{ $this->_actionKind = $actionKind; }

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

/** @param string $actionType */
public function setActionType(string $actionType)
{ $this->_actionType = $actionType; }

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

/** @param string $characteristic */
public function setCharacteristic(string $characteristic)
{ $this->_characteristic = $characteristic; }

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

/** @param string $remark */
public function setRemark(string $remark)
{ $this->_remark = $remark; }

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

/** @param string $originContact */
public function setOriginContact(string $originContact)
{ $this->_originContact = $originContact; }

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

/** @param string $advisorylevel */
public function setAdvisorylevel(string $advisorylevel)
{ $this->_advisorylevel = $advisorylevel; }
}
25 changes: 25 additions & 0 deletions plugin/DataFormConfiguration/DataFormConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ private function createByRow(array $row)
$this->_pGeoPositionFieldHandler->readValues($pConfig);
$rowFields = $this->configureGeoFields($rowFields);

if ($this->_type !== Form::TYPE_APPLICANT_SEARCH){
$rowActivityConfig = $this->_pRecordManagerRead->readActivityConfigByFormId($formId);
$this->configureActivity($pConfig, $rowActivityConfig);
}

foreach ($rowFields as $fieldRow) {
$this->configureFieldsByRow($fieldRow, $pConfig);
}
Expand All @@ -188,6 +193,26 @@ private function createByRow(array $row)
}


/**
* @param DataFormConfiguration\DataFormConfiguration $pFormConfiguration
* @param array|null $row
* @return void
*/
private function configureActivity(DataFormConfiguration\DataFormConfiguration $pFormConfiguration, array $row = null)
{
if (empty($row)) {
return;
}
$pFormConfiguration->setWriteActivity((bool)$row['write_activity'] ?? false);
$pFormConfiguration->setActionKind($row['action_kind'] ?? '');
$pFormConfiguration->setActionType($row['action_type'] ?? '');
$pFormConfiguration->setCharacteristic($row['characteristic'] ?? '');
$pFormConfiguration->setRemark($row['remark'] ?? '');
$pFormConfiguration->setOriginContact($row['origin_contact'] ?? '');
$pFormConfiguration->setAdvisorylevel($row['advisory_level'] ?? '');
}


/**
*
* @param array $row
Expand Down
31 changes: 31 additions & 0 deletions plugin/Form/FormAddressCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use onOffice\WPlugin\Types\FieldsCollection;
use onOffice\WPlugin\Types\FieldTypes;
use onOffice\WPlugin\Language;
use onOffice\WPlugin\DataFormConfiguration\DataFormConfiguration;

/**
*
Expand Down Expand Up @@ -403,4 +404,34 @@ private function getAddressDataForReadAddressApiCall(FormData $pFormData): array

return $addressData;
}

/**
* @param DataFormConfiguration $pFormConfig
* @param int $addressId
* @param int|null $estateId
*/
public function createAgentsLog(DataFormConfiguration $pFormConfig, int $addressId, int $estateId = null)
{
if (empty($pFormConfig->getActionKind()) && empty($pFormConfig->getActionType()) && empty($pFormConfig->getCharacteristic()) && empty($pFormConfig->getRemark())) {
return;
}
$requestParams = [
'addressids' => [$addressId],
'actionkind' => $pFormConfig->getActionKind() ?: null,
'actiontype' => $pFormConfig->getActionType() ?: null,
'origincontact' => $pFormConfig->getOriginContact() ?: null,
'features' => !empty($pFormConfig->getCharacteristic()) ? explode(',', $pFormConfig->getCharacteristic()) : null,
'note' => $pFormConfig->getRemark(),
];

if (!empty($estateId)) {
$requestParams['estateid'] = $estateId;
$requestParams['advisorylevel'] = $pFormConfig->getAdvisorylevel() ?: null;
}

$pApiClientAction = new APIClientActionGeneric
($this->_pSDKWrapper, onOfficeSDK::ACTION_ID_CREATE, 'agentslog');
$pApiClientAction->setParameters($requestParams);
$pApiClientAction->addRequestToQueue()->sendRequests();
}
}
4 changes: 4 additions & 0 deletions plugin/FormPostContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private function createAddress(FormData $pFormData)
{
$pFormConfig = $pFormData->getDataFormConfiguration();
$checkDuplicate = $pFormConfig->getCheckDuplicateOnCreateAddress();
$writeActivity = $pFormConfig->getWriteActivity();
$contactType = $pFormConfig->getContactType();
$pWPQuery = $this->_pFormPostContactConfiguration->getWPQueryWrapper()->getWPQuery();
$estateId = $pWPQuery->get('estate_id', null);
Expand All @@ -156,6 +157,9 @@ private function createAddress(FormData $pFormData)
->createOrCompleteAddress($pFormData, $checkDuplicate, $contactType, $estateId);
$this->_messageDuplicateAddressData = $this->_pFormPostContactConfiguration->getFormAddressCreator()
->getMessageDuplicateAddressData($pFormData, $addressId, $latestAddressIdOnEnterPrise);
if ($writeActivity) {
$this->_pFormPostContactConfiguration->getFormAddressCreator()->createAgentsLog($pFormConfig, $addressId, $estateId);
}

if (!$this->_pFormPostContactConfiguration->getNewsletterAccepted()) {
// No subscription for newsletter, which is ok
Expand Down
4 changes: 4 additions & 0 deletions plugin/FormPostInterest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$contactType = $pFormConfiguration->getContactType();
$pWPQuery = $this->_pFormPostInterestConfiguration->getWPQueryWrapper()->getWPQuery();
$estateId = $pWPQuery->get('estate_id', null);
$writeActivity = $pFormConfiguration->getWriteActivity();
$latestAddressIdOnEnterPrise = null;
if ($checkDuplicate) {
$latestAddressIdOnEnterPrise = $this->_pFormPostInterestConfiguration->getFormAddressCreator()->getLatestAddressIdInOnOfficeEnterprise();
Expand All @@ -98,6 +99,9 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$this->_messageDuplicateAddressData = $this->_pFormPostInterestConfiguration->getFormAddressCreator()
->getMessageDuplicateAddressData($pFormData, $addressId, $latestAddressIdOnEnterPrise);
$this->createSearchcriteria( $pFormData, $addressId );
if ($writeActivity) {
$this->_pFormPostInterestConfiguration->getFormAddressCreator()->createAgentsLog($pFormConfiguration, $addressId, null);
}
$this->setNewsletter( $addressId );
}
} finally {
Expand Down
Loading
Loading