Browse Source

Added select-box instead on input

pull/13242/head
malik masis 4 years ago
parent
commit
daa4f69b50
  1. 14
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/AddWidgetModal.cshtml
  2. 25
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js

14
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/AddWidgetModal.cshtml

@ -16,15 +16,16 @@
} }
<abp-modal size="Large" id="addWidgetModal"> <abp-modal size="Large" id="addWidgetModal">
<abp-modal-header title="@L["AddWidget"].Value"></abp-modal-header> <abp-modal-header title="@L["AddWidget"].Value"></abp-modal-header>
<abp-modal-body> <abp-modal-body>
<div class="container row"> <div class="container row">
@if(Model.Widgets.Count() > 1){ @if(Model.Widgets.Count() > 1)
<abp-select asp-for="ViewModel.Widget" /> {
<div id="PropertySideId"> <abp-select asp-for="ViewModel.Widget" />
</div> <div id="polls" hidden>@await Component.InvokeAsync("CmsPolls")</div>
@*<div id="polls" hidden><abp-select id="Widget" asp-for="ViewModel.Widget" /></div>*@
<div id="PropertySideId">
</div>
<button class="btn btn-primary float-end" type="submit" id="save-changes">@L["Add"]</button> <button class="btn btn-primary float-end" type="submit" id="save-changes">@L["Add"]</button>
} }
else else
@ -33,5 +34,4 @@
} }
</div> </div>
</abp-modal-body> </abp-modal-body>
</abp-modal> </abp-modal>

25
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Contents/addWidgetModal.js

@ -12,16 +12,31 @@ $(function () {
volo.cmsKit.admin.contents.contentAdmin.getWidgets().then(function (data) { volo.cmsKit.admin.contents.contentAdmin.getWidgets().then(function (data) {
var widgetTypes = data.items.filter(v => v.key === widgetType); var widgetTypes = data.items.filter(v => v.key === widgetType);
var firstWidgetType = widgetTypes[0]; var firstWidgetType = widgetTypes[0];
for (const property of firstWidgetType.properties) { if (firstWidgetType.key == "Poll") {
let html = "<div class=\"form-group\"> " + $("#polls").removeAttr("hidden");
" <label for=\"" + property.key + "\">" + property.name + "</label>" + let widgetKey = $('#Widget').find('option:selected').val();
" <input class=\"properties form-control\" id=\"" + property.key + "\" type=\"text\" />" + let html = " <input hidden class=\"properties form-control\" value=\"" + widgetKey + "\" id=\"Code\" type=\"text\" />"
" </div>";
$("#PropertySideId").append(html); $("#PropertySideId").append(html);
} }
else {
for (const property of firstWidgetType.properties) {
let html = "<div class=\"form-group\"> " +
" <label for=\"" + property.key + "\">" + property.name + "</label>" +
" <input class=\"properties form-control\" id=\"" + property.key + "\" type=\"text\" />" +
" </div>";
$("#PropertySideId").append(html);
}
}
}); });
}); });
$("#Widget").change(function () {
$("#PropertySideId").html('');
let widgetKey = $(this).find('option:selected').val();
let html = " <input hidden class=\"properties form-control\" value=\"" + widgetKey + "\" id=\"Code\" type=\"text\" />"
$("#PropertySideId").append(html);
});
$("#save-changes").click(function () { $("#save-changes").click(function () {
var keys = []; var keys = [];
var values = []; var values = [];

Loading…
Cancel
Save