Skip to content

Commit

Permalink
V8: Enable editing the search results directly from Examine Management (
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenn Jacobsen authored and nul800sebastiaan committed Oct 14, 2019
1 parent 529d0fd commit dce4f49
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
24 changes: 23 additions & 1 deletion src/Umbraco.Web.UI.Client/src/common/services/editor.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,27 @@ When building a custom infinite editor view you can use the same components as a
open(editor);
}

/**
* @ngdoc method
* @name umbraco.services.editorService#memberEditor
* @methodOf umbraco.services.editorService
*
* @description
* Opens a member editor in infinite editing, the submit callback returns the updated member
* @param {Object} editor rendering options
* @param {String} editor.id The id (GUID) of the member
* @param {Boolean} editor.create Create new member
* @param {Function} editor.submit Callback function when the submit button is clicked. Returns the editor model object
* @param {Function} editor.close Callback function when the close button is clicked.
* @param {String} editor.doctype If editor.create is true, provide member type for the creation of the member
*
* @returns {Object} editor object
*/
function memberEditor(editor) {
editor.view = "views/member/edit.html";
open(editor);
}

///////////////////////

/**
Expand Down Expand Up @@ -978,7 +999,8 @@ When building a custom infinite editor view you can use the same components as a
itemPicker: itemPicker,
macroPicker: macroPicker,
memberGroupPicker: memberGroupPicker,
memberPicker: memberPicker
memberPicker: memberPicker,
memberEditor: memberEditor
};

return service;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function ExamineManagementController($scope, $http, $q, $timeout, umbRequestHelper, localizationService, overlayService) {
function ExamineManagementController($scope, $http, $q, $timeout, $location, umbRequestHelper, localizationService, overlayService, editorService) {

var vm = this;

Expand All @@ -20,6 +20,7 @@ function ExamineManagementController($scope, $http, $q, $timeout, umbRequestHelp
vm.nextSearchResultPage = nextSearchResultPage;
vm.prevSearchResultPage = prevSearchResultPage;
vm.goToPageSearchResultPage = goToPageSearchResultPage;
vm.goToResult = goToResult;

vm.infoOverlay = null;

Expand Down Expand Up @@ -50,6 +51,45 @@ function ExamineManagementController($scope, $http, $q, $timeout, umbRequestHelp
search(vm.selectedIndex ? vm.selectedIndex : vm.selectedSearcher, null, pageNumber);
}

function goToResult(result, event) {
if (!result.editUrl) {
return;
}
// targeting a new tab/window?
if (event.ctrlKey ||
event.shiftKey ||
event.metaKey || // apple
(event.button && event.button === 1) // middle click, >IE9 + everyone else
) {
// yes, let the link open itself
return;
}

const editor = {
id: result.editId,
submit: function (model) {
editorService.close();
},
close: function () {
editorService.close();
}
};
switch (result.editSection) {
case "content":
editorService.contentEditor(editor);
break;
case "media":
editorService.mediaEditor(editor);
break;
case "member":
editorService.memberEditor(editor);
break;
}

event.stopPropagation();
event.preventDefault();
}

function setViewState(state) {
vm.searchResults = null;
vm.viewState = state;
Expand Down Expand Up @@ -125,6 +165,23 @@ function ExamineManagementController($scope, $http, $q, $timeout, umbRequestHelp
vm.searchResults.pageNumber = pageNumber ? pageNumber : 1;
//20 is page size
vm.searchResults.totalPages = Math.ceil(vm.searchResults.totalRecords / 20);
// add URLs to edit well known entities
_.each(vm.searchResults.results, function (result) {
var section = result.values["__IndexType"];
switch (section) {
case "content":
case "media":
result.editUrl = "/" + section + "/" + section + "/edit/" + result.values["__NodeId"];
result.editId = result.values["__NodeId"];
result.editSection = section;
break;
case "member":
result.editUrl = "/member/member/edit/" + result.values["__Key"];
result.editId = result.values["__Key"];
result.editSection = section;
break;
}
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ <h3 class="bold">Examine Management</h3>
<td>{{result.score}}</td>
<td>{{result.id}}</td>
<td>
<span>{{result.values['nodeName']}}</span>&nbsp;
<a ng-show="result.editUrl" ng-click="vm.goToResult(result, $event)" ng-href="#{{result.editUrl}}">{{result.values['nodeName']}}</a>
<span ng-hide="result.editUrl">{{result.values['nodeName']}}</span>
&nbsp;
<a class="color-green" href="" ng-click="vm.showSearchResultDialog(result.values)">
<em>({{result.fieldCount}} fields)</em>
</a>
Expand Down Expand Up @@ -298,7 +300,9 @@ <h3 class="bold">Examine Management</h3>
<td>{{result.score}}</td>
<td>{{result.id}}</td>
<td>
<span>{{result.values['nodeName']}}</span>&nbsp;
<a ng-show="result.editUrl" ng-click="vm.goToResult(result, $event)" ng-href="#{{result.editUrl}}">{{result.values['nodeName']}}</a>
<span ng-hide="result.editUrl">{{result.values['nodeName']}}</span>
&nbsp;
<a class="color-green" href="" ng-click="vm.showSearchResultDialog(result.values)">
<em>({{result.fieldCount}} fields)</em>
</a>
Expand Down

0 comments on commit dce4f49

Please sign in to comment.