-
Notifications
You must be signed in to change notification settings - Fork 543
Add Language controller to Grand.Web.Store (SaaS per-store language management) #700
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
5 commits
Select commit
Hold shift + click to select a range
4c124ee
Add Language controller and view to Grand.Web.Store, add PrimaryStore…
Copilot 5bdf4fc
Remove PrimaryStoreLanguageId from language settings
KrzysztofPajak 565dcf9
Refactor LanguageController dependencies
KrzysztofPajak 9d36288
fix: use showHidden:true in LanguageController.ListData and expose Pu…
Copilot 8fb6214
Refactor grid settings and language visibility
KrzysztofPajak 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
207 changes: 207 additions & 0 deletions
207
src/Web/Grand.Web.Store/Areas/Store/Views/Language/List.cshtml
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,207 @@ | ||
| @{ | ||
| ViewBag.Title = Loc["Admin.Configuration.Languages"]; | ||
| Layout = Constants.LayoutStore; | ||
| } | ||
|
|
||
| <div class="row"> | ||
| <div class="col-md-12"> | ||
| <div class="x_panel light form-fit"> | ||
| <div class="x_title"> | ||
| <div class="caption"> | ||
| <i class="fa fa-language"></i> | ||
| @Loc["Admin.Configuration.Languages"] | ||
| </div> | ||
| </div> | ||
| <div class="x_content form"> | ||
| <div id="languages-grid"></div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script> | ||
| $(document).ready(function () { | ||
| $("#languages-grid").kendoGrid({ | ||
| dataSource: { | ||
| transport: { | ||
| read: { | ||
| url: "@Html.Raw(Url.Action("ListData", "Language", new { area = Constants.AreaStore }))", | ||
| type: "POST", | ||
| dataType: "json", | ||
| data: addAntiForgeryToken | ||
| } | ||
| }, | ||
| schema: { | ||
| data: "Data", | ||
| total: "Total", | ||
| errors: "Errors" | ||
| }, | ||
| error: function (e) { | ||
| display_kendoui_grid_error(e); | ||
| this.cancelChanges(); | ||
| }, | ||
| serverPaging: false, | ||
| serverFiltering: false, | ||
| serverSorting: false | ||
| }, | ||
| scrollable: false, | ||
| columns: [ | ||
| { | ||
| field: "Name", | ||
| title: "@Loc["Admin.Configuration.Languages.Fields.Name"]", | ||
| width: 200, | ||
| template: function (dataItem) { | ||
| var name = kendo.htmlEncode(dataItem.Name); | ||
| if (dataItem.IsAssignedToCurrentStore) { | ||
| name += ' <span class="badge badge-success" title="@Loc["Admin.Configuration.Languages.AssignStore"]"><i class="fa fa-check"></i></span>'; | ||
| } | ||
| return name; | ||
| } | ||
| }, | ||
| { | ||
| field: "LanguageCulture", | ||
| title: "@Loc["Admin.Configuration.Languages.Fields.LanguageCulture"]", | ||
| width: 120 | ||
| }, | ||
| { | ||
| field: "LimitedToStores", | ||
| title: "@Loc["Admin.Configuration.Languages.Fields.LimitedToStores"]", | ||
| width: 120, | ||
| headerAttributes: { style: "text-align:center" }, | ||
| attributes: { style: "text-align:center" }, | ||
| template: '# if(LimitedToStores) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #' | ||
| }, | ||
| { | ||
| field: "Published", | ||
| title: "@Loc["Admin.Configuration.Languages.Fields.Published"]", | ||
| width: 100, | ||
| headerAttributes: { style: "text-align:center" }, | ||
| attributes: { style: "text-align:center" }, | ||
| template: '# if(Published) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #' | ||
| }, | ||
| { | ||
| field: "IsDefaultStoreLanguage", | ||
| title: "@Loc["Admin.Configuration.Languages.SetDefaultLanguage"]", | ||
| width: 200, | ||
| headerAttributes: { style: "text-align:center" }, | ||
| attributes: { style: "text-align:center" }, | ||
| template: function (dataItem) { | ||
| if (dataItem.IsDefaultStoreLanguage) { | ||
| return '<span class="badge badge-info"><i class="fa fa-home"></i> @Loc["Admin.Configuration.Languages.SetDefaultLanguage"]</span> ' + | ||
| '<a onclick="unsetDefaultLanguage(\'' + dataItem.Id + '\')" class="btn btn-sm btn-warning" title="@Loc["Admin.Configuration.Languages.UnsetDefaultLanguage"]"><i class="fa fa-home"></i> @Loc["Admin.Configuration.Languages.UnsetDefaultLanguage"]</a>'; | ||
| } | ||
| if (dataItem.IsAssignedToCurrentStore) { | ||
| return '<a onclick="setDefaultLanguage(\'' + dataItem.Id + '\')" class="btn btn-sm btn-info" title="@Loc["Admin.Configuration.Languages.SetDefaultLanguage"]"><i class="fa fa-home"></i> @Loc["Admin.Configuration.Languages.SetDefaultLanguage"]</a>'; | ||
| } | ||
| return '<span class="text-muted">-</span>'; | ||
| } | ||
| }, | ||
| { | ||
| title: "@Loc["Admin.Common.Actions"]", | ||
| width: 220, | ||
| headerAttributes: { style: "text-align:center" }, | ||
| attributes: { style: "text-align:center" }, | ||
| template: function (dataItem) { | ||
| if (!dataItem.CanManage) { | ||
| return '<span class="text-muted">-</span>'; | ||
| } | ||
| if (dataItem.IsAssignedToCurrentStore) { | ||
| return '<a onclick="unassignStore(\'' + dataItem.Id + '\')" class="btn btn-sm btn-danger" title="@Loc["Admin.Configuration.Languages.UnassignStore"]"><i class="fa fa-minus"></i> @Loc["Admin.Configuration.Languages.UnassignStore"]</a>'; | ||
| } | ||
| return '<a onclick="assignStore(\'' + dataItem.Id + '\')" class="btn btn-sm btn-success" title="@Loc["Admin.Configuration.Languages.AssignStore"]"><i class="fa fa-plus"></i> @Loc["Admin.Configuration.Languages.AssignStore"]</a>'; | ||
| } | ||
| } | ||
| ] | ||
| }); | ||
| }); | ||
|
|
||
| function assignStore(id) { | ||
| var postData = { id: id }; | ||
| addAntiForgeryToken(postData); | ||
| $.ajax({ | ||
| cache: false, | ||
| type: "POST", | ||
| url: "@Html.Raw(Url.Action("AssignStore", "Language", new { area = Constants.AreaStore }))", | ||
| data: postData, | ||
| success: function (data) { | ||
| if (data.success) { | ||
| var grid = $("#languages-grid").data('kendoGrid'); | ||
| grid.dataSource.read(); | ||
| } else { | ||
| alert(data.message); | ||
| } | ||
| }, | ||
| error: function () { | ||
| alert('Failed to update language'); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| function unassignStore(id) { | ||
| if (!confirm('@Loc["Admin.Common.AreYouSure"]')) return; | ||
| var postData = { id: id }; | ||
| addAntiForgeryToken(postData); | ||
| $.ajax({ | ||
| cache: false, | ||
| type: "POST", | ||
| url: "@Html.Raw(Url.Action("UnassignStore", "Language", new { area = Constants.AreaStore }))", | ||
| data: postData, | ||
| success: function (data) { | ||
| if (data.success) { | ||
| var grid = $("#languages-grid").data('kendoGrid'); | ||
| grid.dataSource.read(); | ||
| } else { | ||
| alert(data.message); | ||
| } | ||
| }, | ||
| error: function () { | ||
| alert('Failed to update language'); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| function setDefaultLanguage(id) { | ||
| var postData = { id: id }; | ||
| addAntiForgeryToken(postData); | ||
| $.ajax({ | ||
| cache: false, | ||
| type: "POST", | ||
| url: "@Html.Raw(Url.Action("SetDefaultLanguage", "Language", new { area = Constants.AreaStore }))", | ||
| data: postData, | ||
| success: function (data) { | ||
| if (data.success) { | ||
| var grid = $("#languages-grid").data('kendoGrid'); | ||
| grid.dataSource.read(); | ||
| } else { | ||
| alert(data.message); | ||
| } | ||
| }, | ||
| error: function () { | ||
| alert('Failed to set default language'); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| function unsetDefaultLanguage(id) { | ||
| if (!confirm('@Loc["Admin.Common.AreYouSure"]')) return; | ||
| var postData = { id: id }; | ||
| addAntiForgeryToken(postData); | ||
| $.ajax({ | ||
| cache: false, | ||
| type: "POST", | ||
| url: "@Html.Raw(Url.Action("UnsetDefaultLanguage", "Language", new { area = Constants.AreaStore }))", | ||
| data: postData, | ||
| success: function (data) { | ||
| if (data.success) { | ||
| var grid = $("#languages-grid").data('kendoGrid'); | ||
| grid.dataSource.read(); | ||
| } else { | ||
| alert(data.message); | ||
| } | ||
| }, | ||
| error: function () { | ||
| alert('Failed to unset default language'); | ||
| } | ||
| }); | ||
| } | ||
| </script> | ||
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.