-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
352 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
class CustomInput < SimpleForm::Inputs::StringInput | ||
def input(wrapper_options = nil) | ||
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options) | ||
template.text_field_tag(attribute_name, nil, merged_input_options) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
|
||
export default class extends Controller { | ||
static targets = ["modal", "modalNameInput", "formNameInput"]; | ||
|
||
connect() { | ||
console.log("exit modal controller connected"); | ||
} | ||
|
||
showModal(event) { | ||
event.preventDefault(); | ||
this.modalTarget.classList.remove("d-none"); | ||
this.modalNameInputTarget.value = this.formNameInputTarget.value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class Offer::CreateAsDraft < Offer::ApplicationService | ||
def call | ||
@offer.save(validate: false) | ||
@service.reindex | ||
@offer.reindex | ||
@offer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
class Offer::UpdateAsDraft < Offer::ApplicationService | ||
def initialize(offer, params) | ||
super(offer) | ||
@params = params | ||
end | ||
|
||
def call | ||
public_before = @offer.published? | ||
@offer.status = "draft" | ||
effective_params = @offer.service.offers.published.size == 1 ? @params : @params.merge(default: false) | ||
|
||
if effective_params["primary_oms_id"] && OMS.find(effective_params["primary_oms_id"])&.custom_params.blank? | ||
effective_params["oms_params"] = {} | ||
end | ||
@offer.assign_attributes(effective_params) | ||
@offer.save(validate: false) | ||
unbundle! if public_before | ||
@offer.service.reindex | ||
|
||
@offer.valid? | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
app/views/backoffice/services/offers/_exit_modal.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.exit-popup.d-none{ role: "document", "data-exit-target": "modal" } | ||
.modal-overlay | ||
.modal-content | ||
.modal-header | ||
%h3#popup-modal-title.modal-title | ||
Exit offer editor | ||
.modal-body | ||
%p | ||
= _("Name your draft to save your offer draft and complete the configuration later.") | ||
= f.input :name, | ||
as: :custom, | ||
input_html: { class: "form-control-lg", "data-exit-target": "modalNameInput"} | ||
.modal-footer | ||
.buttons-row | ||
= link_to _("Exit without saving"), | ||
backoffice_service_path(service), | ||
class: "btn-sm btn-secondary", | ||
"data-action": "click->exit#saveDraft" | ||
= f.button :submit, "Save as draft", class: "btn-sm btn-primary" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.