-
Notifications
You must be signed in to change notification settings - Fork 24
chore(compat): [2.x] upgrade to match sylius version two #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2a34ac8
chore(codebase): [dir] move to new file structure
maxperei 4d6d56e
feat(codebase): [upgrade] sylius v2.x compatibility
maxperei f9cc7d0
chore(ci): [actions] bump to match latest versions
maxperei 0bc04d5
chore(lint): [grumphp] quality tools
maxperei 717cbff
fix(ci): [setup] update paths relative to install folder
maxperei 5480582
fix(ci): [deprecation] apply latest change according to doctrine/orm
maxperei 8d71616
fix(tests): [env] unused variables
maxperei a3bfb26
fix(tests): [kernel] rm useless method
maxperei 8e66d13
fix(tests): [attributes] empty array translation collection due to mi…
maxperei c0a2ff9
chore(deprecation): [entity] get rid of admin api configuration
maxperei b7e2b91
chore(entity): [apip] use proper attribute for api resource metadata …
maxperei 1c21f66
chore(entity): [orm] get rid of annotations
maxperei 655fc12
chore(config): [service] remove unneeded migration
maxperei 62c2855
chore(config): [route] use absolute plugin path
maxperei b178dbe
chore(credit): [import] add author and link to the process manager
maxperei 768c72f
chore(tests): [abstract] remove unused kernel test case
maxperei 8e8ae37
chore(form): [validation] create validation group for taxon attribute…
maxperei 64ce3d8
fix(twig): [hook] missing fallback url on cancel template
maxperei 8ddf902
chore(ci): [actions] run on sylius 2.1
maxperei e90fa66
chore(admin): [templates] remove unused
maxperei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ jobs: | |
| - 8.3 | ||
| symfony: | ||
| - '6.4.*' | ||
| - '7.2.*' | ||
| env: | ||
| APP_ENV: test | ||
| steps: | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
|
|
||
| /tests/Application/ | ||
| /install/Application/*.local | ||
| /install/app-* | ||
|
|
||
| /behat.yml | ||
| /phpspec.yml | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,86 @@ | ||
| import { Controller } from '@hotwired/stimulus'; | ||
| import $ from 'jquery'; | ||
| import '../legacy/js/sylius-form-collection.js'; | ||
|
|
||
| /* stimulusFetch: 'lazy' */ | ||
| export default class extends Controller { | ||
| static values = { | ||
| std: String, | ||
| adv: String, | ||
| }; | ||
| static targets = ['switch']; | ||
| initialize() { | ||
| this.options = { | ||
| locale: { | ||
| trigger: "#product_filter_rule_simple_completeness_type", | ||
| selector: "#product_filter_rule_simple_locales", | ||
| values: [ | ||
| "GREATER THAN ON ALL LOCALES", | ||
| "GREATER OR EQUALS THAN ON ALL LOCALES", | ||
| "LOWER THAN ON ALL LOCALES", | ||
| "LOWER OR EQUALS THAN ON ALL LOCALES", | ||
| ], | ||
| }, | ||
| before: { | ||
| trigger: "#product_filter_rule_simple_updated_mode", | ||
| selector: "#product_filter_rule_simple_updated_before", | ||
| values: ["BETWEEN", "<"], | ||
| }, | ||
| after: { | ||
| trigger: "#product_filter_rule_simple_updated_mode", | ||
| selector: "#product_filter_rule_simple_updated_after", | ||
| values: ["BETWEEN", ">"], | ||
| }, | ||
| since: { | ||
| trigger: "#product_filter_rule_simple_updated_mode", | ||
| selector: "#product_filter_rule_simple_updated", | ||
| values: ["SINCE LAST N DAYS"], | ||
| }, | ||
| } | ||
| } | ||
| connect() { | ||
| this.toggleFields(); | ||
| $('[data-form-type="collection"]').CollectionForm(); | ||
| if (!this.hasSwitchTarget) { | ||
| return; | ||
| } | ||
| if (this.switchTarget.checked || this.switchTarget.querySelector('input:checked')) { | ||
| this.switchTarget.dispatchEvent(new CustomEvent('input')); | ||
| } | ||
| } | ||
| toggleForms(e) { | ||
| if (this.hasStdValue && this.hasAdvValue) { | ||
| $(e.currentTarget).is(':checked') | ||
| ? $('button[type=submit]').attr('form', this.advValue) | ||
| : $('button[type=submit]').attr('form', this.stdValue); | ||
| } | ||
| $(".form-switch > label").toggleClass("opacity-50"); | ||
| $(".togglable").toggle(); | ||
| } | ||
| toggleFields() { | ||
| const toHide = [ | ||
| this.options.locale.selector, | ||
| this.options.before.selector, | ||
| this.options.after.selector, | ||
| this.options.since.selector, | ||
| ]; | ||
| for (let k in this.options) { | ||
| if (this.options[k].values.includes($(this.options[k].trigger).val())) { | ||
| let index = toHide.indexOf(this.options[k].selector); | ||
| if (index !== -1) { | ||
| toHide.splice(index, 1); | ||
| } | ||
| } | ||
| if ($(this.options[k].trigger).length) { | ||
| $(this.options[k].trigger).on("change", (e) => { | ||
| this.options[k].values.includes($(e.currentTarget).val()) | ||
| ? $(this.options[k].selector).parent(".field").removeClass("d-none") | ||
| : $(this.options[k].selector).parent(".field").addClass("d-none"); | ||
| }); | ||
| } | ||
| } | ||
| if ($(`${toHide.join()}`).length) { | ||
| $(`${toHide.join()}`).parent(".field").addClass("d-none"); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,134 @@ | ||
| /* | ||
| * This file is part of the Sylius package. | ||
| * | ||
| * (c) Sylius Sp. z o.o. | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| import $ from 'jquery'; | ||
|
|
||
| /** | ||
| * Collection Form plugin | ||
| * | ||
| * @param element | ||
| * @constructor | ||
| */ | ||
| class CollectionForm { | ||
| constructor(element) { | ||
| this.addItem = this.addItem.bind(this); | ||
| this.updateItem = this.updateItem.bind(this); | ||
| this.deleteItem = this.constructor.deleteItem; | ||
| this.updatePrototype = this.updatePrototype.bind(this); | ||
|
|
||
| this.$element = $(element); | ||
| this.$list = this.$element.find('[data-form-collection="list"]:first'); | ||
| this.count = this.$list.children().length; | ||
| this.lastChoice = null; | ||
| this.$element.on('click', '[data-form-collection="add"]:last', this.addItem); | ||
| this.$element.on('click', '[data-form-collection="delete"]', this.deleteItem); | ||
| this.$element.on('change', '[data-form-collection="update"]', this.updateItem); | ||
| $(document).on('change', '[data-form-prototype="update"]', this.updatePrototype); | ||
| $(document).on('collection-form-add', (event, addedElement) => { | ||
| $(addedElement).find('[data-form-type="collection"]').CollectionForm(); | ||
| $(document).trigger('dom-node-inserted', [$(addedElement)]); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Add a item to the collection. | ||
| * @param event | ||
| */ | ||
| addItem(event) { | ||
| event.preventDefault(); | ||
|
|
||
| let prototype = this.$element.data('prototype'); | ||
| let prototypeName = new RegExp(this.$element.data('prototype-name'), 'g'); | ||
|
|
||
| prototype = prototype.replace(prototypeName, this.count); | ||
|
|
||
| this.$list.append(prototype); | ||
| this.count = this.count + 1; | ||
|
|
||
| $(document).trigger('collection-form-add', [this.$list.children().last()]); | ||
| } | ||
|
|
||
| /** | ||
| * Update item from the collection | ||
| */ | ||
| updateItem(event) { | ||
| event.preventDefault(); | ||
| const $element = $(event.currentTarget); | ||
| const url = $element.data('form-url'); | ||
| const value = $element.val(); | ||
| const $container = $element.closest('[data-form-collection="item"]'); | ||
| const index = $container.data('form-collection-index'); | ||
| const position = $container.data('form-collection-index'); | ||
|
|
||
| if (url) { | ||
| $container.load(url, { id: value, position }); | ||
| } else { | ||
| let $prototype = this.$element.find(`[data-form-prototype="${value}"]`); | ||
| let prototypeName = new RegExp($prototype.data('subprototype-name'), 'g'); | ||
|
|
||
| let prototype = $prototype.val().replace(prototypeName, index); | ||
|
|
||
| $container.replaceWith(prototype); | ||
| } | ||
| $(document).trigger('collection-form-update', [$(event.currentTarget)]); | ||
| } | ||
|
|
||
| /** | ||
| * Delete item from the collection | ||
| * @param event | ||
| */ | ||
| static deleteItem(event) { | ||
| event.preventDefault(); | ||
|
|
||
| $(event.currentTarget) | ||
| .closest('[data-form-collection="item"]') | ||
| .remove(); | ||
|
|
||
| $(document).trigger('collection-form-delete', [$(event.currentTarget)]); | ||
| } | ||
|
|
||
| /** | ||
| * Update the prototype | ||
| * @param event | ||
| */ | ||
| updatePrototype(event) { | ||
| const $target = $(event.currentTarget); | ||
| let prototypeName = $target.val(); | ||
|
|
||
| if ($target.data('form-prototype-prefix') !== undefined) { | ||
| prototypeName = $target.data('form-prototype-prefix') + prototypeName; | ||
| } | ||
|
|
||
| if (this.lastChoice !== null && this.lastChoice !== prototypeName) { | ||
| this.$list.html(''); | ||
| } | ||
|
|
||
| this.lastChoice = prototypeName; | ||
|
|
||
| this.$element.data('prototype', this.$element.find(`[data-form-prototype="${prototypeName}"]`).val()); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * Plugin definition | ||
| */ | ||
|
|
||
| $.fn.CollectionForm = function CollectionFormPlugin(option) { | ||
| this.each((idx, el) => { | ||
| const $element = $(el); | ||
| const data = $element.data('collectionForm'); | ||
| const options = typeof option === 'object' && option; | ||
|
|
||
| if (!data) { | ||
| $element.data('collectionForm', new CollectionForm(el, options)); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| $.fn.CollectionForm.Constructor = CollectionForm; |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.