Skip to content

Commit

Permalink
add revert button
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriyAndriyovuch committed Sep 16, 2023
1 parent f8acd86 commit 58a23c5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/assets/stylesheets/pages/feature_flags.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ input[type="submit"] {
cursor: pointer;
font-size: 16px;
padding: 10px;
min-width: 100px;
min-width: 110px;

&:hover {
background-color: $dark_green;
}
}

.btn-revert {
background-color: rgb(255, 65, 65) !important;

&:hover {
background-color: darkred !important;
}
}
12 changes: 12 additions & 0 deletions app/controllers/account/site_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ def update
end
end

def revert
@site_setting = resource

Check warning on line 21 in app/controllers/account/site_settings_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/site_settings_controller.rb#L21

Added line #L21 was not covered by tests

@site_setting.update(title: "Zero Waste", favicon: {

Check warning on line 23 in app/controllers/account/site_settings_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/site_settings_controller.rb#L23

Added line #L23 was not covered by tests
io: File.open("app/assets/images/logo_zerowaste.png"),
filename: "logo_zerowaste.png",
content_type: "image/png"
})

redirect_to edit_account_site_setting_path, notice: t("notifications.site_setting_reverted")

Check warning on line 29 in app/controllers/account/site_settings_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/site_settings_controller.rb#L29

Added line #L29 was not covered by tests
end

private

def resource
Expand Down
2 changes: 2 additions & 0 deletions app/views/account/site_settings/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ fieldset.bordered
= f.submit t("buttons.update")
i.fa.fa-times-circle

= button_to t("buttons.revert"), account_site_settings_revert_path, method: :get, class: "btn-revert mt-2"

fieldset.bordered
legend.admin-legend
= t(".site_features")
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ en:
update: 'Update'
create: 'Create'
cancel: 'Cancel'
revert: 'Revert'
calculators:
new_calculator:
form:
Expand Down Expand Up @@ -487,6 +488,7 @@ en:
category_deleted: "Category was successfully destroyed."
feature_flags_updated: "Features updated successfully"
site_setting_updated: "Setting was successfully updated"
site_setting_reverted: "Setting was successfully reverted"
# time:
# formats:
# long: '%A, %d %B, %Y'
Expand Down
2 changes: 2 additions & 0 deletions config/locales/uk/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ uk:
update: 'Оновити'
create: 'Створити'
cancel: 'Скасувати'
revert: 'Скинути'
calculators:
new_calculator:
form:
Expand Down Expand Up @@ -493,6 +494,7 @@ uk:
category_deleted: "Категорію було успішно видалено."
feature_flags_updated: "Оновлено успішно"
site_setting_updated: "Налаштування було успішно оновлено"
site_setting_reverted: "Налаштування було успішно скинуто"
# time:
# formats:
# long: '%A, %d %B, %Y'
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
resource :app_config, only: [:edit, :update]
patch "/feature_flags", to: "feature_flags#update", as: "features_flags"
resource :site_setting, only: [:edit, :update]
get "site_settings/revert", to: "site_settings#revert"

scope module: :calculators do
resources :calculators, only: [], param: :slug do
Expand Down

0 comments on commit 58a23c5

Please sign in to comment.