Skip to content

Commit

Permalink
fix: disable ribbon and change success to failure incase edit request…
Browse files Browse the repository at this point in the history
… made via 3rd party
  • Loading branch information
Momik Shrestha committed Jan 17, 2024
1 parent 34ae597 commit f26fe68
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 330 deletions.
51 changes: 28 additions & 23 deletions app/IATI/Elements/Builder/BaseFormCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,51 @@ public function __construct(FormBuilder $formBuilder)
* Returns activity title edit form.
*
* @param array $model
* @param $formData
* @param $formData
* @param $method
* @param $parent_url
* @param string $parent_url
* @param bool $showCancelOrSaveButton
*
* @return Form
*/
public function editForm(array $model, $formData, $method, string $parent_url): Form
public function editForm(array $model, $formData, $method, string $parent_url, bool $showCancelOrSaveButton = true): Form
{
return $this->formBuilder->create(
$form = $this->formBuilder->create(
'App\IATI\Elements\Forms\BaseForm',
[
'method' => $method,
'model' => $model,
'url' => $this->url,
'data' => $formData,
]
)
);

->add('buttons', 'buttongroup', [
'wrapper' => [
'class' => 'fixed left-0 bottom-0 w-full bg-eggshell py-5 pr-20 xl:pr-40 shadow-dropdown',
],
'buttons' => [
'clear' => [
'label' => 'Cancel',
'attr' => [
'type' => 'anchor',
'class' => 'ghost-btn mr-8',
'href' => $parent_url,
],
if ($showCancelOrSaveButton) {
$form->add('buttons', 'buttongroup', [
'wrapper' => [
'class' => 'fixed left-0 bottom-0 w-full bg-eggshell py-5 pr-20 xl:pr-40 shadow-dropdown',
],
'buttons' => [
'clear' => [
'label' => 'Cancel',
'attr' => [
'type' => 'anchor',
'class' => 'ghost-btn mr-8',
'href' => $parent_url,
],
],

'submit' => [
'label' => 'Save and Exit',
'attr' => [
'type' => 'submit',
'class' => 'primary-btn save-btn',
'submit' => [
'label' => 'Save and Exit',
'attr' => [
'type' => 'submit',
'class' => 'primary-btn save-btn',
],
],
],
],
]);
}

return $form;
}
}
6 changes: 4 additions & 2 deletions app/IATI/Services/Activity/ActivityIdentifierService.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function update($id, $activityIdentifier): bool
return $this->activityRepository->update($id, ['iati_identifier' => $activityIdentifier]);
}

return true;
return false;
}

/**
Expand All @@ -97,11 +97,13 @@ public function formGenerator($id): Form
$model['activity_identifier'] = $this->getActivityIdentifierData($id);
$this->baseFormCreator->url = route('admin.activity.identifier.update', [$id]);
$activity = $this->activityRepository->find($id, ['linked_to_iati']);
$showCancelOrSaveButton = true;

if ($activity->linked_to_iati) {
$element['attributes']['activity_identifier']['read_only'] = true;
$showCancelOrSaveButton = false;
}

return $this->baseFormCreator->editForm($model['activity_identifier'], $element, 'PUT', '/activity/' . $id);
return $this->baseFormCreator->editForm($model['activity_identifier'], $element, 'PUT', '/activity/' . $id, $showCancelOrSaveButton);
}
}
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/webportal-app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

Loading

0 comments on commit f26fe68

Please sign in to comment.