add recurrence limit + follow FinanceBuddy installments to stop finite plans (v1.6.1)
This commit is contained in:
@@ -21,8 +21,12 @@ class RecurrenceController extends BaseController
|
||||
$columns = $this->targetColumns($task);
|
||||
$meta = $this->taskMetadataModel->getAll($task['id']);
|
||||
|
||||
// The "Follow FinanceBuddy installments" option only appears when FinanceBuddy is enabled on
|
||||
// this board (installed but not enabled means no installment data to follow).
|
||||
$fb_enabled = (int) $this->projectMetadataModel->get($task['project_id'], 'financebuddy_enabled', 0) === 1;
|
||||
|
||||
if (empty($values)) {
|
||||
$values = $this->getStoredValues($meta, $task, $columns);
|
||||
$values = $this->getStoredValues($meta, $task, $columns, $fb_enabled);
|
||||
}
|
||||
|
||||
$this->response->html($this->template->render('recoReco:recurrence/edit', array(
|
||||
@@ -36,6 +40,9 @@ class RecurrenceController extends BaseController
|
||||
'has_target' => ! empty($columns),
|
||||
'is_clone' => isset($meta['recoreco_clone']) && $meta['recoreco_clone'] == 1,
|
||||
'source_id' => isset($meta['recoreco_source']) ? (int) $meta['recoreco_source'] : 0,
|
||||
'fb_enabled' => $fb_enabled,
|
||||
'fb_current' => isset($meta['financebuddy_installment_current']) ? $meta['financebuddy_installment_current'] : '',
|
||||
'fb_total' => isset($meta['financebuddy_installment_total']) ? $meta['financebuddy_installment_total'] : '',
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -78,6 +85,19 @@ class RecurrenceController extends BaseController
|
||||
$values['recoreco_anchor'] = (int) $task['date_due'];
|
||||
}
|
||||
|
||||
// Finite-plan limit. When FinanceBuddy is enabled on the board and "Follow" is on, RecoReco
|
||||
// reads its installment total/current live at run time -- so nothing is stored here and the
|
||||
// standalone limit/counter are left untouched (the modal greys them). Otherwise store the
|
||||
// standalone limit (blank/0 = forever) and the 1-based progress counter (seedable).
|
||||
$fb_enabled = (int) $this->projectMetadataModel->get($task['project_id'], 'financebuddy_enabled', 0) === 1;
|
||||
$follow = $fb_enabled && isset($input['recoreco_follow_finance']) && $input['recoreco_follow_finance'] == 1;
|
||||
$values['recoreco_follow_finance'] = $follow ? 1 : 0;
|
||||
|
||||
if (! $follow) {
|
||||
$values['recoreco_limit'] = (isset($input['recoreco_limit']) && ctype_digit((string) $input['recoreco_limit'])) ? (int) $input['recoreco_limit'] : 0;
|
||||
$values['recoreco_count'] = (isset($input['recoreco_count']) && ctype_digit((string) $input['recoreco_count']) && (int) $input['recoreco_count'] >= 1) ? (int) $input['recoreco_count'] : 1;
|
||||
}
|
||||
|
||||
$this->taskMetadataModel->save($task['id'], $values);
|
||||
|
||||
// Reconcile the template's duplicate links with the setting right away.
|
||||
@@ -112,7 +132,7 @@ class RecurrenceController extends BaseController
|
||||
return empty($keys) ? 0 : (int) $keys[0];
|
||||
}
|
||||
|
||||
private function getStoredValues(array $meta, array $task, array $columns)
|
||||
private function getStoredValues(array $meta, array $task, array $columns, $fb_enabled)
|
||||
{
|
||||
return array(
|
||||
'recoreco_enabled' => isset($meta['recoreco_enabled']) ? (int) $meta['recoreco_enabled'] : 0,
|
||||
@@ -121,6 +141,10 @@ class RecurrenceController extends BaseController
|
||||
'recoreco_last_day' => isset($meta['recoreco_last_day']) ? (int) $meta['recoreco_last_day'] : 0,
|
||||
'recoreco_days_before' => isset($meta['recoreco_days_before']) ? (int) $meta['recoreco_days_before'] : 0,
|
||||
'recoreco_link_copies' => isset($meta['recoreco_link_copies']) ? (int) $meta['recoreco_link_copies'] : 0,
|
||||
// Follow defaults ON for a fresh card on a FinanceBuddy board; otherwise the stored choice.
|
||||
'recoreco_follow_finance' => isset($meta['recoreco_follow_finance']) ? (int) $meta['recoreco_follow_finance'] : ($fb_enabled ? 1 : 0),
|
||||
'recoreco_limit' => isset($meta['recoreco_limit']) ? (int) $meta['recoreco_limit'] : 0,
|
||||
'recoreco_count' => isset($meta['recoreco_count']) ? (int) $meta['recoreco_count'] : 1,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user