Skip to content

Commit

Permalink
feat(incidens): User can choose between updating component status or not
Browse files Browse the repository at this point in the history
  • Loading branch information
herrtxbias committed Mar 17, 2021
1 parent d43cb71 commit 051be18
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class IncidentAddModal extends Component
public Incident $incident;
public IncidentUpdate $incidentUpdate;
public $incidentComponents;
public bool $doNotUpdateStatus = false;

protected $rules = [
'incident.title' => 'required|string|min:3',
Expand All @@ -28,6 +29,7 @@ class IncidentAddModal extends Component
'incident.visibility' => 'boolean',
'incidentUpdate.text' => 'required|string|min:3',
'incidentComponents' => '',
'doNotUpdateStatus' => 'boolean',
];

public function render()
Expand Down Expand Up @@ -65,11 +67,13 @@ public function save(){
}
}

if(0 <= $this->incident->status && $this->incident->status < 3){
foreach ($this->incident->components()->get() as $component){
$component->update([
'status_id' => $this->incident->impact+2,
]);
if(!$this->doNotUpdateStatus){
if(0 <= $this->incident->status && $this->incident->status < 3){
foreach ($this->incident->components()->get() as $component){
$component->update([
'status_id' => $this->incident->impact+2,
]);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en/incidents.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
'impact' => 'Impact',
'visible' => 'Visible',
'affected_components' => 'Affected Components',
'affected_components_hint' => 'Affected Components will be set automatically into a status, based on the impact.',
'affected_components_hint' => 'Affected Components will be set automatically into a status, based on the impact, unless you deactivate this feature.',
'do_not_update_status' => 'Do not update the Status',
'message' => 'Message',
'open_button' => 'Open Incident',
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<x-jet-input-error for="incidentComponents" class="mt-2" />
</div>

<div class="col-span-6 sm:col-span-4 mb-4">
<x-jet-label for="doNotUpdateStatus" class="text-lg" value="{{ __('incidents.new_incident.modal.do_not_update_status') }}" />
<x-jet-input id="doNotUpdateStatus" type="checkbox" class="mt-1 block" wire:model="doNotUpdateStatus" />
<x-jet-input-error for="doNotUpdateStatus" class="mt-2" />
</div>

<div class="col-span-6 sm:col-span-4 mb-4">
<x-jet-label for="text" class="text-lg" value="{{ __('incidents.new_incident.modal.message') }}" />
<textarea id="text" wire:model="incidentUpdate.text" class="h-96 mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"></textarea>
Expand Down

0 comments on commit 051be18

Please sign in to comment.