Skip to content

Commit

Permalink
fix: the disabling of non-suggested fields is restricted only to edit
Browse files Browse the repository at this point in the history
  • Loading branch information
sriramkanakam87 committed Oct 2, 2024
1 parent 206dc4b commit 7e83f7b
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions app/Filament/Dashboard/Resources/ReportResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,19 @@ public static function form(Form $form): Form

return $geo_locations;
})
->disabled(function (Get $get) {
return ! $get('show_geo_location_existing');
->disabled(function (Get $get, string $operation) {
return ! $get('show_geo_location_existing') && $operation == 'edit';
})
->dehydrated()
->columnSpan(4),
TagsInput::make('new_geo_locations')
->label('New')
->separator(',')
->splitKeys([','])
->disabled(function (Get $get) {
return ! $get('show_geo_location_new');
->disabled(function (Get $get, string $operation) {
return ! $get('show_geo_location_new') && $operation == 'edit';
})
->dehydrated()
->columnSpan(4),
])
->columns(9),
Expand All @@ -197,17 +199,19 @@ public static function form(Form $form): Form

return $synonyms;
})
->disabled(function (Get $get) {
return ! $get('show_synonym_existing');
->disabled(function (Get $get, string $operation) {
return ! $get('show_synonym_existing') && $operation == 'edit';
})
->dehydrated()
->columnSpan(4),
TagsInput::make('new_synonyms')
->label('New')
->separator(',')
->splitKeys([','])
->disabled(function (Get $get) {
return ! $get('show_synonym_new');
->disabled(function (Get $get, string $operation) {
return ! $get('show_synonym_new') && $operation == 'edit';
})
->dehydrated()
->columnSpan(4),
])
->columns(9),
Expand All @@ -226,9 +230,10 @@ public static function form(Form $form): Form
return self::$molecule->name;
}
})
->disabled(function (Get $get) {
return ! $get('show_name_change');
->disabled(function (Get $get, string $operation) {
return ! $get('show_name_change') && $operation == 'edit';
})
->dehydrated()
->columnSpan(4),
])
->columns(9),
Expand All @@ -249,17 +254,19 @@ public static function form(Form $form): Form
return self::$molecule->cas;
}
})
->disabled(function (Get $get) {
return ! $get('show_cas_existing');
->disabled(function (Get $get, string $operation) {
return ! $get('show_cas_existing') && $operation == 'edit';
})
->dehydrated()
->columnSpan(4),
TagsInput::make('new_cas')
->label('New')
->separator(',')
->splitKeys([','])
->disabled(function (Get $get) {
return ! $get('show_cas_new');
->disabled(function (Get $get, string $operation) {
return ! $get('show_cas_new') && $operation == 'edit';
})
->dehydrated()
->columnSpan(4),
])
->columns(9),
Expand All @@ -283,9 +290,10 @@ public static function form(Form $form): Form
return self::$molecule->organisms->pluck('name', 'id')->toArray();
}
})
->disabled(function (Get $get) {
return ! $get('show_organism_existing');
->disabled(function (Get $get, string $operation) {
return ! $get('show_organism_existing') && $operation == 'edit';
})
->dehydrated()
->columnSpan(9),
])
->columns(9),
Expand All @@ -298,17 +306,17 @@ public static function form(Form $form): Form
->hidden(function (string $operation) {
return ! auth()->user()->roles()->exists() || $operation == 'create';
})
->disabled(false)
->columnSpanFull(),
Grid::make('new_organism')
->schema(Organism::getForm())->columns(4),
])
->reorderable(false)
->addActionLabel('Add New Organism')
->defaultItems(0)
->disabled(function (Get $get) {
return ! $get('show_organism_new');
->disabled(function (Get $get, string $operation) {
return ! $get('show_organism_new') && $operation == 'edit';
})
->dehydrated()
->columns(9),

]),
Expand All @@ -331,9 +339,10 @@ public static function form(Form $form): Form
return self::$molecule->citations->where('title', '!=', null)->pluck('title', 'id')->toArray();
}
})
->disabled(function (Get $get) {
return ! $get('show_citation_existing');
->disabled(function (Get $get, string $operation) {
return ! $get('show_citation_existing') && $operation == 'edit';
})
->dehydrated()
->columnSpan(9),
])
->columns(9),
Expand All @@ -352,9 +361,10 @@ public static function form(Form $form): Form
->reorderable(false)
->addActionLabel('Add New Citation')
->defaultItems(0)
->disabled(function (Get $get) {
return ! $get('show_citation_new');
->disabled(function (Get $get, string $operation) {
return ! $get('show_citation_new') && $operation == 'edit';
})
->dehydrated()
->columns(9),

]),
Expand Down Expand Up @@ -646,7 +656,7 @@ public static function approveReport(array $data, Report $record, Molecule $mole

$suggested_changes = $record['suggested_changes'];

$suggested_changes['approved_changes'] = self::$overall_changes;
$suggested_changes['curator']['approved_changes'] = self::$overall_changes;
$record['suggested_changes'] = $suggested_changes;
$record['comment'] = $data['reason'];
$record['status'] = 'approved';
Expand Down

0 comments on commit 7e83f7b

Please sign in to comment.