Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add capability to add existing modules from other sites in site group #4597

Merged
merged 2 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public HttpResponseMessage GetPagesInPortalGroup(int sortOrder = 0)
var response = new
{
Success = true,
Tree = GetPagesInPortalGroupInternal(sortOrder),
Tree = this.GetPagesInPortalGroupInternal(sortOrder),
IgnoreRoot = true,
};
return this.Request.CreateResponse(HttpStatusCode.OK, response);
Expand Down Expand Up @@ -146,6 +146,14 @@ public HttpResponseMessage GetPageDescendantsInPortalGroup(string parentId = nul
Items = this.GetPageDescendantsInPortalGroupInternal(parentId, sortOrder, searchText, includeDisabled, includeAllTypes, includeActive, includeHostPages, roles),
};
return this.Request.CreateResponse(HttpStatusCode.OK, response);
}

[HttpGet]
public HttpResponseMessage GetPortalsInGroup(int sortOrder = 0)
{
var sites = GetPortalGroup(sortOrder);
var portalId = this.PortalSettings.PortalId;
return this.Request.CreateResponse(HttpStatusCode.OK, new { sites, portalId });
}

[HttpGet]
Expand All @@ -170,7 +178,7 @@ public HttpResponseMessage SearchPagesInPortalGroup(string searchText, int sortO
var response = new
{
Success = true,
Tree = string.IsNullOrEmpty(searchText) ? GetPagesInPortalGroupInternal(sortOrder)
Tree = string.IsNullOrEmpty(searchText) ? this.GetPagesInPortalGroupInternal(sortOrder)
: this.SearchPagesInPortalGroupInternal(searchText, sortOrder, includeDisabled, includeAllTypes, includeActive, includeHostPages, roles),
IgnoreRoot = true,
};
Expand Down Expand Up @@ -333,10 +341,10 @@ where string.IsNullOrEmpty(q) || t.Name.IndexOf(q, StringComparison.InvariantCul
return this.Request.CreateResponse(HttpStatusCode.OK, terms);
}

private static NTree<ItemDto> GetPagesInPortalGroupInternal(int sortOrder)
private NTree<ItemDto> GetPagesInPortalGroupInternal(int sortOrder)
{
var treeNode = new NTree<ItemDto> { Data = new ItemDto { Key = RootKey } };
var portals = GetPortalGroup(sortOrder);
var portals = this.GetPortalGroup(sortOrder);
treeNode.Children = portals.Select(dto => new NTree<ItemDto> { Data = dto }).ToList();
return treeNode;
}
Expand Down Expand Up @@ -383,9 +391,9 @@ private static void SortPagesRecursevely(IEnumerable<TabInfo> tabs, NTree<ItemDt
}
}

private static IEnumerable<ItemDto> GetPortalGroup(int sortOrder)
private IEnumerable<ItemDto> GetPortalGroup(int sortOrder)
{
var mygroup = GetMyPortalGroup();
var mygroup = this.GetMyPortalGroup();
var portals = mygroup.Select(p => new ItemDto
{
Key = PortalPrefix + p.PortalID.ToString(CultureInfo.InvariantCulture),
Expand All @@ -409,15 +417,22 @@ private static IEnumerable<ItemDto> ApplySort(IEnumerable<ItemDto> items, int so
}
}

private static IEnumerable<PortalInfo> GetMyPortalGroup()
private IEnumerable<PortalInfo> GetMyPortalGroup()
{
var groups = PortalGroupController.Instance.GetPortalGroups().ToArray();
var mygroup = (from @group in groups
select PortalGroupController.Instance.GetPortalsByGroup(@group.PortalGroupId)
into portals
where portals.Any(x => x.PortalID == PortalSettings.Current.PortalId)
select portals.ToArray()).FirstOrDefault();
return mygroup;
var groups = PortalGroupController.Instance.GetPortalGroups().ToArray();
if (groups.Any())
{
var mygroup = (from @group in groups
select PortalGroupController.Instance.GetPortalsByGroup(@group.PortalGroupId)
into portals
where portals.Any(x => x.PortalID == PortalSettings.Current.PortalId)
select portals.ToArray()).FirstOrDefault();
return mygroup;
}

var currentPortal = new List<PortalInfo>();
currentPortal.Add(PortalController.Instance.GetPortal(this.PortalSettings.PortalId));
return currentPortal;
}

private NTree<ItemDto> GetPagesInternal(int portalId, int sortOrder, bool includeDisabled = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ if (typeof dnn.ContentEditorManager === "undefined" || dnn.ContentEditorManager
moduleId: '',
serviceRoot: 'InternalServices',
rootId: 'Root',
parameters: { includeAllTypes: "true" },
parameters: { includeAllTypes: "true", portalId: options.portalId },
includeDisabled: true
},
onSelectionChangedBackScript: selectPageProxyCallback
Expand All @@ -144,11 +144,12 @@ if (typeof dnn.ContentEditorManager === "undefined" || dnn.ContentEditorManager
dnn.createDropDownList(id, defaultOptions, {});
},

_createPagesDropdown: function () {
_createPagesDropdown: function (portalId) {
var handler = this;
var resx = dnn.ContentEditorManagerResources;
var pagePickerOptions = {
selectPageCallback: $.proxy(handler._onSelectPageChanged, handler),
portalId: portalId,
selectedFolder: -1,
selectedItemCss: 'selected-item',
internalStateFieldId: 'AddExistingModule_FolderPicker_State',
Expand Down Expand Up @@ -200,6 +201,11 @@ if (typeof dnn.ContentEditorManager === "undefined" || dnn.ContentEditorManager
'<div class="dnnDialogBody dnnModuleList">' +
'<div class="dnnModuleHeader">' +
'<ul>' +
'<li class="sites">' +
'<label>' + dnn.ContentEditorManagerResources.site + '</label>' +
'<select id="AddExistingModule_Sites" class="dnnDropDownList site">' +
'</select>' +
'</li>' +
'<li>' +
'<label>' + dnn.ContentEditorManagerResources.page + '</label>' +
'<div id="AddExistingModule_Pages" class="dnnDropDownList page">' +
Expand Down Expand Up @@ -283,6 +289,14 @@ if (typeof dnn.ContentEditorManager === "undefined" || dnn.ContentEditorManager
this._dialogLayout.trigger('dialogopen');
},

_loadSiteList: function() {
if (!this.getModuleDialog()._getItemListService().isLoading()) {
this.getModuleDialog()._getItemListService().request('GetPortalsInGroup', 'GET', {
sortOrder: 0
}, $.proxy(this._renderSiteList, this));
}
},

_loadModuleList: function () {
this._dialogLayout.find('li.dnnModuleItem').remove();
this._dialogLayout.find('div.dnnModuleDialog_ModuleListMessage').remove();
Expand All @@ -300,6 +314,24 @@ if (typeof dnn.ContentEditorManager === "undefined" || dnn.ContentEditorManager
}
},

_renderSiteList: function (data) {
var select = document.querySelector('#AddExistingModule_Sites');
data.sites.forEach((siteInfo, index) => {
var portalId = parseInt(siteInfo.key.substr(2));
var option = document.createElement('option');
option.innerText = siteInfo.value;
option.value = portalId;
select.appendChild(option);
if(data.portalId == portalId) {
select.options[index].setAttribute('selected', '');
}
});
select.addEventListener('change', e => {
var portalId = parseInt(e.target.value);
this._createPagesDropdown(portalId);
});
},

_renderModuleList: function (data) {
var container = this._dialogLayout.find(".dnnModuleList .listContainer.listAll ul");

Expand Down Expand Up @@ -399,8 +431,9 @@ if (typeof dnn.ContentEditorManager === "undefined" || dnn.ContentEditorManager
},

_initUI: function () {
this._createPagesDropdown();
this._createPagesDropdown(undefined);
this._dialogLayout.find('input[type="checkbox"]').dnnCheckbox();
this._loadSiteList();
},

_closeButtonHandler: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,17 @@ if (typeof dnn.ContentEditorManager === "undefined" || dnn.ContentEditorManager
return this._serviceController;
},

_getItemListService: function () {
if (!this._itemListServiceController) {
this._itemListServiceController = new dnn.dnnModuleService({
service: 'internalservices',
controller: 'itemlistservice'
});
}

return this._itemListServiceController;
},

_getEditorService: function () {
if (!this._editorServiceController) {
this._editorServiceController = new dnn.dnnModuleService({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,21 @@
.dnnModuleDialog .dnnModuleHeader .dnnCheckbox {
margin-top: 7px;
}
.dnnModuleDialog .dnnModuleHeader li.sites {
display: flex;
align-items: baseline;
}
.dnnModuleDialog .dnnModuleHeader li.sites select {
border: none;
margin: 0 7px;
font-family: 'Open Sans', Arial, Helvetica, sans-serif;
font-weight: 700;
line-height: 18px;
}
.dnnModuleDialog .dnnModuleHeader li.sites select option {
font-family: 'Open Sans', Arial, Helvetica, sans-serif;
font-weight: 700;
}
.dnnModuleDialog .dnnDropDownList.page {
display: inline-block;
width: auto;
Expand Down