Merge branch 'temp8-3436-relationtypes' into temp8
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @ngdoc service
|
||||
* @name umbraco.resources.relationTypeResource
|
||||
* @description Loads in data for relation types.
|
||||
*/
|
||||
function relationTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
|
||||
return {
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.relationTypeResource#getById
|
||||
* @methodOf umbraco.resources.relationTypeResource
|
||||
*
|
||||
* @description
|
||||
* Gets a relation type with a given ID.
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* relationTypeResource.getById(1234)
|
||||
* .then(function() {
|
||||
* alert('Found it!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @param {Int} id of the relation type to get.
|
||||
* @returns {Promise} resourcePromise containing relation type data.
|
||||
*/
|
||||
getById: function (id) {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(umbRequestHelper.getApiUrl("relationTypeApiBaseUrl", "GetById", [{ id: id }])),
|
||||
"Failed to get item " + id
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.relationTypeResource#getRelationObjectTypes
|
||||
* @methodof umbraco.resources.relationTypeResource
|
||||
*
|
||||
* @description
|
||||
* Gets a list of Umbraco object types which can be associated with a relation.
|
||||
*
|
||||
* @returns {Object} A collection of Umbraco object types.
|
||||
*/
|
||||
getRelationObjectTypes: function() {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl("relationTypeApiBaseUrl", "GetRelationObjectTypes")
|
||||
),
|
||||
"Failed to get object types"
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.relationTypeResource#save
|
||||
* @methodof umbraco.resources.relationTypeResource
|
||||
*
|
||||
* @description
|
||||
* Updates a relation type.
|
||||
*
|
||||
* @param {Object} relationType The relation type object to update.
|
||||
* @returns {Promise} A resourcePromise object.
|
||||
*/
|
||||
save: function (relationType) {
|
||||
var saveModel = umbDataFormatter.formatRelationTypePostData(relationType);
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(umbRequestHelper.getApiUrl("relationTypeApiBaseUrl", "PostSave"), saveModel),
|
||||
"Failed to save data for relation type ID" + relationType.id
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.relationTypeResource#create
|
||||
* @methodof umbraco.resources.relationTypeResource
|
||||
*
|
||||
* @description
|
||||
* Creates a new relation type.
|
||||
*
|
||||
* @param {Object} relationType The relation type object to create.
|
||||
* @returns {Promise} A resourcePromise object.
|
||||
*/
|
||||
create: function (relationType) {
|
||||
var createModel = umbDataFormatter.formatRelationTypePostData(relationType);
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(umbRequestHelper.getApiUrl("relationTypeApiBaseUrl", "PostCreate"), createModel),
|
||||
"Failed to create new realtion"
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.relationTypeResource#deleteById
|
||||
* @methodof umbraco.resources.relationTypeResource
|
||||
*
|
||||
* @description
|
||||
* Deletes a relation type with a given ID.
|
||||
*
|
||||
* * ## Usage
|
||||
* <pre>
|
||||
* relationTypeResource.deleteById(1234).then(function() {
|
||||
* alert('Deleted it!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @param {Int} id The ID of the relation type to delete.
|
||||
* @returns {Promose} resourcePromise object.
|
||||
*/
|
||||
deleteById: function (id) {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(umbRequestHelper.getApiUrl("relationTypeApiBaseUrl", "DeleteById", [{ id: id }])),
|
||||
"Failed to delete item " + id
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
angular.module("umbraco.resources").factory("relationTypeResource", relationTypeResource);
|
||||
@@ -431,6 +431,24 @@
|
||||
}
|
||||
|
||||
return displayModel;
|
||||
},
|
||||
|
||||
/**
|
||||
* Formats the display model used to display the relation type to a model used to save the relation type.
|
||||
* @param {Object} relationType
|
||||
*/
|
||||
formatRelationTypePostData : function(relationType) {
|
||||
var saveModel = {
|
||||
id: relationType.id,
|
||||
name: relationType.name,
|
||||
alias: relationType.alias,
|
||||
key : relationType.key,
|
||||
isBidirectional: relationType.isBidirectional,
|
||||
parentObjectType: relationType.parentObjectType,
|
||||
childObjectType: relationType.childObjectType
|
||||
};
|
||||
|
||||
return saveModel;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @ngdoc controller
|
||||
* @name Umbraco.Editors.RelationTypes.CreateController
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* The controller for creating relation types.
|
||||
*/
|
||||
function RelationTypeCreateController($scope, $location, relationTypeResource, navigationService, formHelper, appState, notificationsService) {
|
||||
var vm = this;
|
||||
vm.relationType = {};
|
||||
vm.objectTypes = {};
|
||||
|
||||
vm.createRelationType = createRelationType;
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
relationTypeResource.getRelationObjectTypes().then(function (data) {
|
||||
vm.objectTypes = data;
|
||||
}, function (err) {
|
||||
notificationsService.error("Could not load form.")
|
||||
})
|
||||
}
|
||||
|
||||
function createRelationType() {
|
||||
if (formHelper.submitForm({ scope: $scope, formCtrl: this.createRelationTypeForm, statusMessage: "Creating relation type..." })) {
|
||||
var node = $scope.currentNode;
|
||||
|
||||
relationTypeResource.create(vm.relationType).then(function (data) {
|
||||
navigationService.hideMenu();
|
||||
|
||||
// Set the new item as active in the tree
|
||||
var currentPath = node.path ? node.path : "-1";
|
||||
navigationService.syncTree({ tree: "relationTypes", path: currentPath + "," + data, forceReload: true, activate: true });
|
||||
|
||||
formHelper.resetForm({ scope: $scope });
|
||||
|
||||
var currentSection = appState.getSectionState("currentSection");
|
||||
$location.path("/" + currentSection + "/relationTypes/edit/" + data);
|
||||
}, function (err) {
|
||||
if (err.data && err.data.message) {
|
||||
notificationsService.error(err.data.message);
|
||||
navigationService.hideMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.RelationTypes.CreateController", RelationTypeCreateController);
|
||||
@@ -0,0 +1,58 @@
|
||||
<div class="umbracoDialog umb-dialog-body with-footer" ng-controller="Umbraco.Editors.RelationTypes.CreateController as vm" ng-cloak>
|
||||
<div class="umb-pane">
|
||||
<form name="createRelationTypeForm" val-form-manager ng-submit="vm.createRelationType()">
|
||||
<!-- Name -->
|
||||
<umb-control-group label="@relationType_name">
|
||||
<input type="text" name="relationTypeName" ng-model="vm.relationType.name" class="umb-textstring textstring input-block-level" umb-auto-focus required />
|
||||
</umb-control-group>
|
||||
|
||||
<!-- Direction -->
|
||||
<umb-control-group label="@relationType_direction">
|
||||
<ul class="unstyled">
|
||||
<li>
|
||||
<label class="radio">
|
||||
<input type="radio" name="relationType-direction" ng-model="vm.relationType.isBidirectional" ng-value="false">
|
||||
<localize key="relationType_parentToChild">Parent to child</localize>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="radio">
|
||||
<input type="radio" name="relationType-direction" ng-model="vm.relationType.isBidirectional" ng-value="true">
|
||||
<localize key="relationType_bidirectional">Bidirectional</localize>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</umb-control-group>
|
||||
|
||||
<!-- Parent -->
|
||||
<umb-control-group label="@relationType_parent">
|
||||
<select name="relationType-parent"
|
||||
ng-model="vm.relationType.parentObjectType"
|
||||
class="umb-property-editor umb-dropdown"
|
||||
required>
|
||||
<option ng-repeat="objectType in vm.objectTypes" value="{{objectType.id}}">{{objectType.name}}</option>
|
||||
</select>
|
||||
</umb-control-group>
|
||||
|
||||
<!-- Child -->
|
||||
<umb-control-group label="@relationType_child">
|
||||
<select name="relationType-child"
|
||||
ng-model="vm.relationType.childObjectType"
|
||||
class="umb-property-editor umb-dropdown"
|
||||
required>
|
||||
<option ng-repeat="objectType in vm.objectTypes" value="{{objectType.id}}">{{objectType.name}}</option>
|
||||
</select>
|
||||
</umb-control-group>
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<localize key="general_create">Create</localize>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
|
||||
<button class="btn btn-info">
|
||||
<localize key="buttons_somethingElse">Do something else</localize>
|
||||
</button>
|
||||
</div>
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @ngdoc controller
|
||||
* @name Umbraco.Editors.RelationTypes.DeleteController
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* The controller for deleting relation types.
|
||||
*/
|
||||
function RelationTypeDeleteController($scope, $location, relationTypeResource, treeService, navigationService, appState) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.cancel = cancel;
|
||||
vm.performDelete = performDelete;
|
||||
|
||||
function cancel() {
|
||||
navigationService.hideDialog();
|
||||
}
|
||||
|
||||
function performDelete() {
|
||||
// stop from firing again on double-click
|
||||
if ($scope.busy) { return false; }
|
||||
|
||||
//mark it for deletion (used in the UI)
|
||||
$scope.currentNode.loading = true;
|
||||
$scope.busy = true;
|
||||
|
||||
relationTypeResource.deleteById($scope.currentNode.id).then(function () {
|
||||
$scope.currentNode.loading = false;
|
||||
|
||||
treeService.removeNode($scope.currentNode);
|
||||
|
||||
navigationService.hideMenu();
|
||||
|
||||
var currentSection = appState.getSectionState("currentSection");
|
||||
$location.path("/" + currentSection + "/");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.RelationTypes.DeleteController", RelationTypeDeleteController);
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="umb-dialog umb-pane" ng-controller="Umbraco.Editors.RelationTypes.DeleteController as vm">
|
||||
<div class="umb-dialog-body" auto-scale="90">
|
||||
|
||||
<p class="umb-abstract">
|
||||
<localize key="defaultdialogs_confirmdelete">Are you sure you want to delete</localize> <strong>{{currentNode.name}}</strong>?
|
||||
</p>
|
||||
|
||||
<umb-confirm on-confirm="vm.performDelete" on-cancel="vm.cancel">
|
||||
</umb-confirm>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @ngdoc controller
|
||||
* @name Umbraco.Editors.RelationTypes.EditController
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* The controller for editing relation types.
|
||||
*/
|
||||
function RelationTypeEditController($scope, $routeParams, relationTypeResource, editorState, navigationService, dateHelper, userService, entityResource, formHelper, contentEditingHelper, localizationService) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.page = {};
|
||||
vm.page.loading = false;
|
||||
vm.page.saveButtonState = "init";
|
||||
vm.page.menu = {}
|
||||
|
||||
vm.save = saveRelationType;
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
vm.page.loading = true;
|
||||
|
||||
localizationService.localizeMany(["relationType_tabRelationType", "relationType_tabRelations"]).then(function (data) {
|
||||
vm.page.navigation = [
|
||||
{
|
||||
"name": data[0],
|
||||
"alias": "relationType",
|
||||
"icon": "icon-info",
|
||||
"view": "views/relationTypes/views/relationType.html",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"name": data[1],
|
||||
"alias": "relations",
|
||||
"icon": "icon-trafic",
|
||||
"view": "views/relationTypes/views/relations.html"
|
||||
}
|
||||
];
|
||||
});
|
||||
|
||||
relationTypeResource.getById($routeParams.id)
|
||||
.then(function(data) {
|
||||
bindRelationType(data);
|
||||
vm.page.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
function bindRelationType(relationType) {
|
||||
formatDates(relationType.relations);
|
||||
getRelationNames(relationType);
|
||||
|
||||
vm.relationType = relationType;
|
||||
|
||||
editorState.set(vm.relationType);
|
||||
|
||||
navigationService.syncTree({ tree: "relationTypes", path: relationType.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
}
|
||||
|
||||
function formatDates(relations) {
|
||||
if(relations) {
|
||||
userService.getCurrentUser().then(function (currentUser) {
|
||||
angular.forEach(relations, function (relation) {
|
||||
relation.timestampFormatted = dateHelper.getLocalDate(relation.createDate, currentUser.locale, 'LLL');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getRelationNames(relationType) {
|
||||
if(relationType.relations) {
|
||||
angular.forEach(relationType.relations, function(relation){
|
||||
entityResource.getById(relation.parentId, relationType.parentObjectTypeName).then(function(entity) {
|
||||
relation.parentName = entity.name;
|
||||
});
|
||||
entityResource.getById(relation.childId, relationType.childObjectTypeName).then(function(entity) {
|
||||
relation.childName = entity.name;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function saveRelationType() {
|
||||
vm.page.saveButtonState = "busy";
|
||||
|
||||
if (formHelper.submitForm({ scope: $scope, statusMessage: "Saving..." })) {
|
||||
relationTypeResource.save(vm.relationType).then(function (data) {
|
||||
formHelper.resetForm({ scope: $scope, notifications: data.notifications });
|
||||
bindRelationType(data);
|
||||
vm.page.saveButtonState = "success";
|
||||
}, function (error) {
|
||||
contentEditingHelper.handleSaveError({
|
||||
redirectOnFailure: false,
|
||||
err: error
|
||||
});
|
||||
|
||||
notificationsService.error(error.data.message);
|
||||
vm.page.saveButtonState = "error";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.RelationTypes.EditController", RelationTypeEditController);
|
||||
@@ -0,0 +1,33 @@
|
||||
<div data-element="editor-relation-types" ng-controller="Umbraco.Editors.RelationTypes.EditController as vm">
|
||||
<umb-load-indicator ng-if="vm.page.loading"></umb-load-indicator>
|
||||
|
||||
<form name="relationTypeForm" novalidate val-form-manager ng-submit="vm.save()">
|
||||
<umb-editor-view ng-if="!vm.page.loading">
|
||||
<umb-editor-header
|
||||
name="vm.relationType.name"
|
||||
alias="vm.relationType.alias"
|
||||
hide-description="true"
|
||||
hide-icon="true"
|
||||
navigation="vm.page.navigation">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container class="form-horizontal">
|
||||
<umb-editor-sub-views sub-views="vm.page.navigation" model="vm">
|
||||
</umb-editor-sub-views>
|
||||
</umb-editor-container>
|
||||
|
||||
<umb-editor-footer>
|
||||
<umb-editor-footer-content-right>
|
||||
<umb-button
|
||||
type="submit"
|
||||
button-style="success"
|
||||
state="vm.page.saveButtonState"
|
||||
shortcut="ctrl+s"
|
||||
label="Save"
|
||||
label-key="buttons_save">
|
||||
</umb-button>
|
||||
</umb-editor-footer-content-right>
|
||||
</umb-editor-footer>
|
||||
</umb-editor-view>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,40 @@
|
||||
<umb-box>
|
||||
<umb-box-content>
|
||||
<!-- ID -->
|
||||
<umb-control-group label="Id">
|
||||
<div>{{model.relationType.id}}</div>
|
||||
<small>{{model.relationType.key}}</small>
|
||||
</umb-control-group>
|
||||
|
||||
<!-- Direction -->
|
||||
<umb-control-group label="@relationType_direction">
|
||||
<ul class="unstyled">
|
||||
<li>
|
||||
<label class="radio">
|
||||
<input type="radio" name="relationType-direction" ng-model="model.relationType.isBidirectional" ng-value="false"> <localize key="relationType_parentToChild">Parent to child</localize>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="radio">
|
||||
<input type="radio" name="relationType-direction" ng-model="model.relationType.isBidirectional" ng-value="true"> <localize key="relationType_bidirectional">Bidirectional</localize>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</umb-control-group>
|
||||
|
||||
<!-- Parent-->
|
||||
<umb-control-group label="@relationType_parent">
|
||||
<div>{{model.relationType.parentObjectTypeName}}</div>
|
||||
</umb-control-group>
|
||||
|
||||
<!-- Child -->
|
||||
<umb-control-group label="@relationType_child">
|
||||
<div>{{model.relationType.childObjectTypeName}}</div>
|
||||
</umb-control-group>
|
||||
|
||||
<!-- Relation count -->
|
||||
<umb-control-group label="@relationType_count" ng-if="model.relationType.relations.length > 0">
|
||||
<div>{{model.relationType.relations.length}}</div>
|
||||
</umb-control-group>
|
||||
</umb-box-content>
|
||||
</umb-box>
|
||||
@@ -0,0 +1,23 @@
|
||||
<umb-box>
|
||||
<umb-box-content>
|
||||
<!-- Relations -->
|
||||
<umb-control-group label="@relationType_relations" ng-if="model.relationType.relations.length > 0">
|
||||
<div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th><localize key="relationType_parent">Parent</localize></th>
|
||||
<th><localize key="relationType_child">Child</localize></th>
|
||||
<th><localize key="relationType_created">Created</localize></th>
|
||||
<th><localize key="relationType_comment">Comment</localize></th>
|
||||
</thead>
|
||||
<tr ng-repeat="relation in model.relationType.relations">
|
||||
<td>{{relation.parentName}}</td>
|
||||
<td>{{relation.childName}}</td>
|
||||
<td>{{relation.timestampFormatted}}</td>
|
||||
<td>{{relation.comment}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
</umb-box-content>
|
||||
</umb-box>
|
||||
@@ -1965,4 +1965,18 @@ To manage your website, simply open the Umbraco back office and start adding con
|
||||
<key alias="noRestoreRelation">There is no 'restore' relation found for this node. Use the Move menu item to move it manually.</key>
|
||||
<key alias="restoreUnderRecycled">The item you want to restore it under ('%0%') is in the recycle bin. Use the Move menu item to move the item manually.</key>
|
||||
</area>
|
||||
<area alias="relationType">
|
||||
<key alias="direction">Direction</key>
|
||||
<key alias="parentToChild">Parent to child</key>
|
||||
<key alias="bidirectional">Bidirectional</key>
|
||||
<key alias="parent">Parent</key>
|
||||
<key alias="child">Child</key>
|
||||
<key alias="count">Count</key>
|
||||
<key alias="relations">Relations</key>
|
||||
<key alias="created">Created</key>
|
||||
<key alias="comment">Comment</key>
|
||||
<key alias="name">Name</key>
|
||||
<key alias="tabRelationType">Relation Type</key>
|
||||
<key alias="tabRelations">Relations</key>
|
||||
</area>
|
||||
</language>
|
||||
|
||||
@@ -2020,4 +2020,18 @@ To manage your website, simply open the Umbraco back office and start adding con
|
||||
<key alias="notifySet">Select your notifications for</key>
|
||||
<key alias="notificationsSavedFor">Notification settings saved for </key>
|
||||
</area>
|
||||
<area alias="relationType">
|
||||
<key alias="direction">Direction</key>
|
||||
<key alias="parentToChild">Parent to child</key>
|
||||
<key alias="bidirectional">Bidirectional</key>
|
||||
<key alias="parent">Parent</key>
|
||||
<key alias="child">Child</key>
|
||||
<key alias="count">Count</key>
|
||||
<key alias="relations">Relations</key>
|
||||
<key alias="created">Created</key>
|
||||
<key alias="comment">Comment</key>
|
||||
<key alias="name">Name</key>
|
||||
<key alias="tabRelationType">Relation Type</key>
|
||||
<key alias="tabRelations">Relations</key>
|
||||
</area>
|
||||
</language>
|
||||
|
||||
@@ -299,6 +299,10 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
"languageApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<LanguageController>(
|
||||
controller => controller.GetAllLanguages())
|
||||
},
|
||||
{
|
||||
"relationTypeApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<RelationTypeController>(
|
||||
controller => controller.GetById(1))
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -6,40 +6,40 @@ using System.Web.Http;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
using Relation = Umbraco.Web.Models.ContentEditing.Relation;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
[PluginController("UmbracoApi")]
|
||||
[UmbracoApplicationAuthorizeAttribute(Constants.Applications.Content)]
|
||||
[UmbracoApplicationAuthorize(Constants.Applications.Content)]
|
||||
public class RelationController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
public Relation GetById(int id)
|
||||
public RelationDisplay GetById(int id)
|
||||
{
|
||||
return Mapper.Map<IRelation, Relation>(Services.RelationService.GetById(id));
|
||||
return Mapper.Map<IRelation, RelationDisplay>(Services.RelationService.GetById(id));
|
||||
}
|
||||
|
||||
//[EnsureUserPermissionForContent("childId")]
|
||||
public IEnumerable<Relation> GetByChildId(int childId, string relationTypeAlias = "")
|
||||
public IEnumerable<RelationDisplay> GetByChildId(int childId, string relationTypeAlias = "")
|
||||
{
|
||||
var relations = Services.RelationService.GetByChildId(childId).ToArray();
|
||||
|
||||
if (relations.Any() == false)
|
||||
{
|
||||
return Enumerable.Empty<Relation>();
|
||||
return Enumerable.Empty<RelationDisplay>();
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(relationTypeAlias) == false)
|
||||
{
|
||||
return
|
||||
Mapper.Map<IEnumerable<IRelation>, IEnumerable<Relation>>(
|
||||
Mapper.Map<IEnumerable<IRelation>, IEnumerable<RelationDisplay>>(
|
||||
relations.Where(x => x.RelationType.Alias.InvariantEquals(relationTypeAlias)));
|
||||
}
|
||||
|
||||
return Mapper.Map<IEnumerable<IRelation>, IEnumerable<Relation>>(relations);
|
||||
return Mapper.Map<IEnumerable<IRelation>, IEnumerable<RelationDisplay>>(relations);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// The API controller for editing relation types.
|
||||
/// </summary>
|
||||
[PluginController("UmbracoApi")]
|
||||
[UmbracoTreeAuthorize(Constants.Trees.RelationTypes)]
|
||||
[EnableOverrideAuthorization]
|
||||
public class RelationTypeController : BackOfficeNotificationsController
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a relation type by ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The relation type ID.</param>
|
||||
/// <returns>Returns the <see cref="RelationTypeDisplay"/>.</returns>
|
||||
public RelationTypeDisplay GetById(int id)
|
||||
{
|
||||
var relationType = Services.RelationService.GetRelationTypeById(id);
|
||||
|
||||
if (relationType == null)
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var relations = Services.RelationService.GetByRelationTypeId(relationType.Id);
|
||||
|
||||
var display = Mapper.Map<IRelationType, RelationTypeDisplay>(relationType);
|
||||
display.Relations = Mapper.Map<IEnumerable<IRelation>, IEnumerable<RelationDisplay>>(relations);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of object types which can be associated via relations.
|
||||
/// </summary>
|
||||
/// <returns>A list of available object types.</returns>
|
||||
public List<ObjectType> GetRelationObjectTypes()
|
||||
{
|
||||
var objectTypes = new List<ObjectType>
|
||||
{
|
||||
new ObjectType{Id = UmbracoObjectTypes.Document.GetGuid(), Name = UmbracoObjectTypes.Document.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.Media.GetGuid(), Name = UmbracoObjectTypes.Media.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.Member.GetGuid(), Name = UmbracoObjectTypes.Member.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.DocumentType.GetGuid(), Name = UmbracoObjectTypes.DocumentType.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.MediaType.GetGuid(), Name = UmbracoObjectTypes.MediaType.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.MemberType.GetGuid(), Name = UmbracoObjectTypes.MemberType.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.DataType.GetGuid(), Name = UmbracoObjectTypes.DataType.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.MemberGroup.GetGuid(), Name = UmbracoObjectTypes.MemberGroup.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.Stylesheet.GetGuid(), Name = UmbracoObjectTypes.Stylesheet.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.ROOT.GetGuid(), Name = UmbracoObjectTypes.ROOT.GetFriendlyName()},
|
||||
new ObjectType{Id = UmbracoObjectTypes.RecycleBin.GetGuid(), Name = UmbracoObjectTypes.RecycleBin.GetFriendlyName()},
|
||||
};
|
||||
|
||||
return objectTypes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new relation type.
|
||||
/// </summary>
|
||||
/// <param name="relationType">The relation type to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the persisted relation type's ID.</returns>
|
||||
public HttpResponseMessage PostCreate(RelationTypeSave relationType)
|
||||
{
|
||||
var relationTypePersisted = new RelationType(relationType.ChildObjectType, relationType.ParentObjectType, relationType.Name.ToSafeAlias(true))
|
||||
{
|
||||
Name = relationType.Name,
|
||||
IsBidirectional = relationType.IsBidirectional
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
Services.RelationService.Save(relationTypePersisted);
|
||||
|
||||
return Request.CreateResponse(HttpStatusCode.OK, relationTypePersisted.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(GetType(), ex, "Error creating relation type with {Name}", relationType.Name);
|
||||
return Request.CreateNotificationValidationErrorResponse("Error creating relation type.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing relation type.
|
||||
/// </summary>
|
||||
/// <param name="relationType">The relation type to update.</param>
|
||||
/// <returns>A display object containing the updated relation type.</returns>
|
||||
public RelationTypeDisplay PostSave(RelationTypeSave relationType)
|
||||
{
|
||||
var relationTypePersisted = Services.RelationService.GetRelationTypeById(relationType.Key);
|
||||
|
||||
if (relationTypePersisted == null)
|
||||
{
|
||||
throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Relation type does not exist"));
|
||||
}
|
||||
|
||||
Mapper.Map(relationType, relationTypePersisted);
|
||||
|
||||
try
|
||||
{
|
||||
Services.RelationService.Save(relationTypePersisted);
|
||||
var display = Mapper.Map<RelationTypeDisplay>(relationTypePersisted);
|
||||
display.AddSuccessNotification("Relation type saved", "");
|
||||
|
||||
return display;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(GetType(), ex, "Error saving relation type with {Id}", relationType.Id);
|
||||
throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Something went wrong when saving the relation type"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a relation type with a given ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the relation type to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/>.</returns>
|
||||
[HttpPost]
|
||||
[HttpDelete]
|
||||
public HttpResponseMessage DeleteById(int id)
|
||||
{
|
||||
var relationType = Services.RelationService.GetRelationTypeById(id);
|
||||
|
||||
if(relationType == null)
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
|
||||
Services.RelationService.Delete(relationType);
|
||||
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "objectType", Namespace = "")]
|
||||
public class ObjectType
|
||||
{
|
||||
[DataMember(Name = "name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DataMember(Name = "id")]
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relation", Namespace = "")]
|
||||
public class Relation
|
||||
{
|
||||
|
||||
public Relation()
|
||||
{
|
||||
RelationType = new RelationType();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent Id of the Relation (Source)
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentId")]
|
||||
public int ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child Id of the Relation (Destination)
|
||||
/// </summary>
|
||||
[DataMember(Name = "childId")]
|
||||
public int ChildId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="RelationType"/> for the Relation
|
||||
/// </summary>
|
||||
[DataMember(Name = "relationType", IsRequired = true)]
|
||||
public RelationType RelationType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a comment for the Relation
|
||||
/// </summary>
|
||||
[DataMember(Name = "comment")]
|
||||
public string Comment { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relation", Namespace = "")]
|
||||
public class RelationDisplay
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent Id of the Relation (Source).
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentId")]
|
||||
[ReadOnly(true)]
|
||||
public int ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent Name of the relation (Source).
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentName")]
|
||||
[ReadOnly(true)]
|
||||
public string ParentName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child Id of the Relation (Destination).
|
||||
/// </summary>
|
||||
[DataMember(Name = "childId")]
|
||||
[ReadOnly(true)]
|
||||
public int ChildId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child Name of the relation (Destination).
|
||||
/// </summary>
|
||||
[DataMember(Name = "childName")]
|
||||
[ReadOnly(true)]
|
||||
public string ChildName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date when the Relation was created.
|
||||
/// </summary>
|
||||
[DataMember(Name = "createDate")]
|
||||
[ReadOnly(true)]
|
||||
public DateTime CreateDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a comment for the Relation.
|
||||
/// </summary>
|
||||
[DataMember(Name = "comment")]
|
||||
[ReadOnly(true)]
|
||||
public string Comment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relationType", Namespace = "")]
|
||||
public class RelationType
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Name of the RelationType
|
||||
/// </summary>
|
||||
[DataMember(Name = "name", IsRequired = true)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Alias of the RelationType
|
||||
/// </summary>
|
||||
[DataMember(Name = "alias", IsRequired = true)]
|
||||
public string Alias { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the RelationType is Bidirectional (true) or Parent to Child (false)
|
||||
/// </summary>
|
||||
[DataMember(Name = "isBidirectional", IsRequired = true)]
|
||||
public bool IsBidirectional { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parents object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "parentObjectType", IsRequired = true)]
|
||||
public Guid ParentObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Childs object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "childObjectType", IsRequired = true)]
|
||||
public Guid ChildObjectType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relationType", Namespace = "")]
|
||||
public class RelationTypeDisplay : EntityBasic, INotificationModel
|
||||
{
|
||||
public RelationTypeDisplay()
|
||||
{
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the RelationType is Bidirectional (true) or Parent to Child (false)
|
||||
/// </summary>
|
||||
[DataMember(Name = "isBidirectional", IsRequired = true)]
|
||||
public bool IsBidirectional { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parents object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "parentObjectType", IsRequired = true)]
|
||||
public Guid ParentObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent's object type name.
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentObjectTypeName")]
|
||||
[ReadOnly(true)]
|
||||
public string ParentObjectTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Childs object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "childObjectType", IsRequired = true)]
|
||||
public Guid ChildObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child's object type name.
|
||||
/// </summary>
|
||||
[DataMember(Name = "childObjectTypeName")]
|
||||
[ReadOnly(true)]
|
||||
public string ChildObjectTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the relations associated with this relation type.
|
||||
/// </summary>
|
||||
[DataMember(Name = "relations")]
|
||||
[ReadOnly(true)]
|
||||
public IEnumerable<RelationDisplay> Relations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
[DataMember(Name = "notifications")]
|
||||
public List<Notification> Notifications { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relationType", Namespace = "")]
|
||||
public class RelationTypeSave : EntityBasic
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the RelationType is Bidirectional (true) or Parent to Child (false)
|
||||
/// </summary>
|
||||
[DataMember(Name = "isBidirectional", IsRequired = true)]
|
||||
public bool IsBidirectional { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parent object type ID.
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentObjectType", IsRequired = false)]
|
||||
public Guid ParentObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the child object type ID.
|
||||
/// </summary>
|
||||
[DataMember(Name = "childObjectType", IsRequired = false)]
|
||||
public Guid ChildObjectType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Relation = Umbraco.Web.Models.ContentEditing.Relation;
|
||||
using RelationType = Umbraco.Web.Models.ContentEditing.RelationType;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -9,11 +9,35 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public RelationMapperProfile()
|
||||
{
|
||||
//FROM IRelationType TO RelationType
|
||||
CreateMap<IRelationType, RelationType>();
|
||||
// FROM IRelationType to RelationTypeDisplay
|
||||
CreateMap<IRelationType, RelationTypeDisplay>()
|
||||
.ForMember(x => x.Icon, expression => expression.Ignore())
|
||||
.ForMember(x => x.Trashed, expression => expression.Ignore())
|
||||
.ForMember(x => x.Alias, expression => expression.Ignore())
|
||||
.ForMember(x => x.Path, expression => expression.Ignore())
|
||||
.ForMember(x => x.AdditionalData, expression => expression.Ignore())
|
||||
.ForMember(x => x.ChildObjectTypeName, expression => expression.Ignore())
|
||||
.ForMember(x => x.ParentObjectTypeName, expression => expression.Ignore())
|
||||
.ForMember(x => x.Relations, expression => expression.Ignore())
|
||||
.ForMember(
|
||||
x => x.Udi,
|
||||
expression => expression.MapFrom(
|
||||
content => Udi.Create(Constants.UdiEntityType.RelationType, content.Key)))
|
||||
.AfterMap((src, dest) =>
|
||||
{
|
||||
// Build up the path
|
||||
dest.Path = "-1," + src.Id;
|
||||
|
||||
//FROM IRelation TO Relation
|
||||
CreateMap<IRelation, Relation>();
|
||||
// Set the "friendly" names for the parent and child object types
|
||||
dest.ParentObjectTypeName = ObjectTypes.GetUmbracoObjectType(src.ParentObjectType).GetFriendlyName();
|
||||
dest.ChildObjectTypeName = ObjectTypes.GetUmbracoObjectType(src.ChildObjectType).GetFriendlyName();
|
||||
});
|
||||
|
||||
// FROM IRelation to RelationDisplay
|
||||
CreateMap<IRelation, RelationDisplay>();
|
||||
|
||||
// FROM RelationTypeSave to IRelationType
|
||||
CreateMap<RelationTypeSave, IRelationType>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Core;
|
||||
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Web.Actions;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
@@ -25,8 +21,8 @@ namespace Umbraco.Web.Trees
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
//Create the normal create action
|
||||
var addMenuItem = menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
|
||||
addMenuItem.LaunchDialogUrl("developer/RelationTypes/NewRelationType.aspx", "Create New RelationType");
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.ActionAlias));
|
||||
|
||||
//refresh action
|
||||
menu.Items.Add(new RefreshNode(Services.TextService, true));
|
||||
|
||||
@@ -36,17 +32,7 @@ namespace Umbraco.Web.Trees
|
||||
var relationType = Services.RelationService.GetRelationTypeById(int.Parse(id));
|
||||
if (relationType == null) return new MenuItemCollection();
|
||||
|
||||
//add delete option for all macros
|
||||
menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true)
|
||||
//Since we haven't implemented anything for relationtypes in angular, this needs to be converted to
|
||||
//use the legacy format
|
||||
.ConvertLegacyMenuItem(new EntitySlim
|
||||
{
|
||||
Id = relationType.Id,
|
||||
Level = 1,
|
||||
ParentId = -1,
|
||||
Name = relationType.Name
|
||||
}, "relationTypes", queryStrings.GetValue<string>("application"));
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.ActionAlias));
|
||||
|
||||
return menu;
|
||||
}
|
||||
@@ -57,18 +43,9 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
nodes.AddRange(Services.RelationService
|
||||
.GetAllRelationTypes().Select(rt => CreateTreeNode(
|
||||
rt.Id.ToString(),
|
||||
id,
|
||||
queryStrings,
|
||||
rt.Name,
|
||||
"icon-trafic",
|
||||
false,
|
||||
//TODO: Rebuild the macro editor in angular, then we dont need to have this at all (which is just a path to the legacy editor)
|
||||
"/" + queryStrings.GetValue<string>("application") + "/framed/" +
|
||||
Uri.EscapeDataString("/umbraco/developer/RelationTypes/EditRelationType.aspx?id=" + rt.Id)
|
||||
)));
|
||||
nodes.AddRange(Services.RelationService.GetAllRelationTypes()
|
||||
.Select(rt => CreateTreeNode(rt.Id.ToString(), id, queryStrings, rt.Name,
|
||||
"icon-trafic", false)));
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<Compile Include="Components\BackOfficeUserAuditEventsComponent.cs" />
|
||||
<Compile Include="ContentApps\ListViewContentAppFactory.cs" />
|
||||
<Compile Include="Editors\BackOfficePreviewModel.cs" />
|
||||
<Compile Include="Editors\RelationTypeController.cs" />
|
||||
<Compile Include="Logging\WebProfiler.cs" />
|
||||
<Compile Include="Logging\WebProfilerComponent.cs" />
|
||||
<Compile Include="Logging\WebProfilerProvider.cs" />
|
||||
@@ -151,6 +152,10 @@
|
||||
<Compile Include="Media\TypeDetector\SvgDetector.cs" />
|
||||
<Compile Include="Media\TypeDetector\TIFFDetector.cs" />
|
||||
<Compile Include="Media\UploadAutoFillProperties.cs" />
|
||||
<Compile Include="Models\ContentEditing\ObjectType.cs" />
|
||||
<Compile Include="Models\ContentEditing\RelationDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\RelationTypeDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\RelationTypeSave.cs" />
|
||||
<Compile Include="Models\ContentEditing\RollbackVersion.cs" />
|
||||
<Compile Include="Models\ContentEditing\SearchResult.cs" />
|
||||
<Compile Include="Models\ContentEditing\SearchResults.cs" />
|
||||
@@ -627,9 +632,7 @@
|
||||
<Compile Include="UI\JavaScript\UmbracoClientDependencyLoader.cs" />
|
||||
<Compile Include="UmbracoDefaultOwinStartup.cs" />
|
||||
<Compile Include="IUmbracoContextAccessor.cs" />
|
||||
<Compile Include="Models\ContentEditing\Relation.cs" />
|
||||
<Compile Include="HtmlStringUtilities.cs" />
|
||||
<Compile Include="Models\ContentEditing\RelationType.cs" />
|
||||
<Compile Include="ITagQuery.cs" />
|
||||
<Compile Include="IUmbracoComponentRenderer.cs" />
|
||||
<Compile Include="Models\Mapping\RelationMapperProfile.cs" />
|
||||
@@ -1239,13 +1242,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx.designer.cs">
|
||||
<DependentUpon>FeedProxy.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx.cs">
|
||||
<DependentUpon>NewRelationType.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx.designer.cs">
|
||||
<DependentUpon>NewRelationType.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx.cs">
|
||||
<DependentUpon>insertMasterpageContent.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1317,9 +1313,6 @@
|
||||
<EmbeddedResource Include="UI\JavaScript\PreviewInitialize.js" />
|
||||
<!--<Content Include="umbraco.presentation\umbraco\users\PermissionEditor.aspx" />-->
|
||||
<Content Include="PublishedCache\NuCache\notes.txt" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewRelationType.aspx.cs" Inherits="umbraco.cms.presentation.developer.RelationTypes.NewRelationType" MasterPageFile="../../masterpages/umbracoPage.Master"%>
|
||||
<%@ Register TagPrefix="umb" Namespace="Umbraco.Web._Legacy.Controls" %>
|
||||
|
||||
|
||||
<asp:Content ID="bodyContent" ContentPlaceHolderID="body" runat="server">
|
||||
|
||||
|
||||
<umb:Pane ID="nameAliasPane" runat="server" Text="">
|
||||
|
||||
<umb:PropertyPanel runat="server" ID="nameProperyPanel" Text="Name">
|
||||
<asp:TextBox ID="descriptionTextBox" runat="server" Columns="40" AutoCompleteType="Disabled" style="width:200px;" />
|
||||
<asp:RequiredFieldValidator ID="descriptionRequiredFieldValidator" runat="server" ControlToValidate="descriptionTextBox" ValidationGroup="NewRelationType" ErrorMessage="Name Required" Display="Dynamic" />
|
||||
</umb:PropertyPanel>
|
||||
|
||||
<umb:PropertyPanel runat="server" id="aliasPropertyPanel" Text="Alias">
|
||||
<asp:TextBox ID="aliasTextBox" runat="server" Columns="40" AutoCompleteType="Disabled" style="width:200px;" />
|
||||
<asp:RequiredFieldValidator ID="aliasRequiredFieldValidator" runat="server" ControlToValidate="aliasTextBox" ValidationGroup="NewRelationType" ErrorMessage="Alias Required" Display="Dynamic" />
|
||||
<asp:CustomValidator ID="aliasCustomValidator" runat="server" ControlToValidate="aliasTextBox" ValidationGroup="NewRelationType" onservervalidate="AliasCustomValidator_ServerValidate" ErrorMessage="Duplicate Alias" Display="Dynamic" />
|
||||
</umb:PropertyPanel>
|
||||
|
||||
</umb:Pane>
|
||||
<umb:Pane ID="directionPane" runat="server" Text="">
|
||||
|
||||
<umb:PropertyPanel runat="server" id="PropertyPanel1" Text="Direction">
|
||||
<asp:RadioButtonList ID="dualRadioButtonList" runat="server" RepeatDirection="Horizontal">
|
||||
<asp:ListItem Enabled="true" Selected="True" Text="Parent to Child" Value="0"/>
|
||||
<asp:ListItem Enabled="true" Selected="False" Text="Bidirectional" Value="1"/>
|
||||
</asp:RadioButtonList>
|
||||
</umb:PropertyPanel>
|
||||
<% ///*<asp:RequiredFieldValidator ID="dualRequiredFieldValidator" runat="server" ControlToValidate="dualRadioButtonList" ValidationGroup="NewRelationType" ErrorMessage="Direction Required" Display="Dynamic" /> */ %>
|
||||
|
||||
|
||||
</umb:Pane>
|
||||
<umb:Pane ID="objectTypePane" runat="server" Text="">
|
||||
|
||||
<umb:PropertyPanel runat="server" id="PropertyPanel2" Text="Parent">
|
||||
<asp:DropDownList ID="parentDropDownList" runat="server" />
|
||||
</umb:PropertyPanel>
|
||||
|
||||
<umb:PropertyPanel runat="server" id="PropertyPanel3" Text="Child">
|
||||
<asp:DropDownList ID="childDropDownList" runat="server" />
|
||||
</umb:PropertyPanel>
|
||||
|
||||
</umb:Pane>
|
||||
|
||||
<div style="margin-top:15px">
|
||||
<asp:Button ID="addButton" runat="server" Text="Create" onclick="AddButton_Click" CausesValidation="true" ValidationGroup="NewRelationType" />
|
||||
<em>or</em>
|
||||
<a onclick="top.UmbClientMgr.closeModalWindow()" style="color: blue;" href="#">Cancel</a>
|
||||
</div>
|
||||
|
||||
|
||||
</asp:Content>
|
||||
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
using System;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace umbraco.cms.presentation.developer.RelationTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Add a new Relation Type
|
||||
/// </summary>
|
||||
[WebformsPageTreeAuthorize(Constants.Trees.RelationTypes)]
|
||||
public partial class NewRelationType : UmbracoEnsuredPage
|
||||
{
|
||||
/// <summary>
|
||||
/// On Load event
|
||||
/// </summary>
|
||||
/// <param name="sender">this aspx page</param>
|
||||
/// <param name="e">EventArgs (expect empty)</param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!this.Page.IsPostBack)
|
||||
{
|
||||
this.Form.DefaultFocus = this.descriptionTextBox.ClientID;
|
||||
}
|
||||
|
||||
this.AppendUmbracoObjectTypes(this.parentDropDownList);
|
||||
this.AppendUmbracoObjectTypes(this.childDropDownList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Server side validation to ensure there are no existing relationshipTypes with the alias of
|
||||
/// the relation type being added
|
||||
/// </summary>
|
||||
/// <param name="source">the aliasCustomValidator control</param>
|
||||
/// <param name="args">to set validation respose</param>
|
||||
protected void AliasCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
|
||||
{
|
||||
var relationService = Services.RelationService;
|
||||
args.IsValid = relationService.GetRelationTypeByAlias(this.aliasTextBox.Text.Trim()) == null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a new relation type into the database, and redirects to it's editing page.
|
||||
/// </summary>
|
||||
/// <param name="sender">expects the addButton control</param>
|
||||
/// <param name="e">expects EventArgs for addButton</param>
|
||||
protected void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid)
|
||||
{
|
||||
var newRelationTypeAlias = this.aliasTextBox.Text.Trim();
|
||||
|
||||
var relationService = Services.RelationService;
|
||||
var relationType = new RelationType(new Guid(this.childDropDownList.SelectedValue),
|
||||
new Guid(this.parentDropDownList.SelectedValue), newRelationTypeAlias, this.descriptionTextBox.Text)
|
||||
{
|
||||
IsBidirectional = this.dualRadioButtonList.SelectedValue == "1"
|
||||
};
|
||||
|
||||
relationService.Save(relationType);
|
||||
|
||||
var newRelationTypeId = relationService.GetRelationTypeByAlias(newRelationTypeAlias).Id;
|
||||
|
||||
ClientTools.ChangeContentFrameUrl("developer/RelationTypes/EditRelationType.aspx?id=" + newRelationTypeId).CloseModalWindow().ChildNodeCreated();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the Umbraco Object types to a drop down list
|
||||
/// </summary>
|
||||
/// <param name="dropDownList">control for which to add the Umbraco object types</param>
|
||||
private void AppendUmbracoObjectTypes(ListControl dropDownList)
|
||||
{
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.Document.GetFriendlyName(), Constants.ObjectTypes.Strings.Document));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.Media.GetFriendlyName(), Constants.ObjectTypes.Strings.Media));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.Member.GetFriendlyName(), Constants.ObjectTypes.Strings.Member));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.MediaType.GetFriendlyName(), Constants.ObjectTypes.Strings.MediaType));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.DocumentType.GetFriendlyName(), Constants.ObjectTypes.Strings.DocumentType));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.MemberType.GetFriendlyName(), Constants.ObjectTypes.Strings.MemberType));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.DataType.GetFriendlyName(), Constants.ObjectTypes.Strings.DataType));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.MemberGroup.GetFriendlyName(), Constants.ObjectTypes.Strings.MemberGroup));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.Stylesheet.GetFriendlyName(), Constants.ObjectTypes.Strings.Stylesheet));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.Template.GetFriendlyName(), Constants.ObjectTypes.Strings.Template));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.ROOT.GetFriendlyName(), Constants.ObjectTypes.Strings.SystemRoot));
|
||||
dropDownList.Items.Add(new ListItem(UmbracoObjectTypes.RecycleBin.GetFriendlyName(), Constants.ObjectTypes.Strings.ContentRecycleBin));
|
||||
}
|
||||
}
|
||||
}
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.cms.presentation.developer.RelationTypes {
|
||||
|
||||
|
||||
public partial class NewRelationType {
|
||||
|
||||
/// <summary>
|
||||
/// nameAliasPane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane nameAliasPane;
|
||||
|
||||
/// <summary>
|
||||
/// nameProperyPanel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel nameProperyPanel;
|
||||
|
||||
/// <summary>
|
||||
/// descriptionTextBox control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox descriptionTextBox;
|
||||
|
||||
/// <summary>
|
||||
/// descriptionRequiredFieldValidator control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RequiredFieldValidator descriptionRequiredFieldValidator;
|
||||
|
||||
/// <summary>
|
||||
/// aliasPropertyPanel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel aliasPropertyPanel;
|
||||
|
||||
/// <summary>
|
||||
/// aliasTextBox control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox aliasTextBox;
|
||||
|
||||
/// <summary>
|
||||
/// aliasRequiredFieldValidator control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RequiredFieldValidator aliasRequiredFieldValidator;
|
||||
|
||||
/// <summary>
|
||||
/// aliasCustomValidator control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.CustomValidator aliasCustomValidator;
|
||||
|
||||
/// <summary>
|
||||
/// directionPane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane directionPane;
|
||||
|
||||
/// <summary>
|
||||
/// PropertyPanel1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel PropertyPanel1;
|
||||
|
||||
/// <summary>
|
||||
/// dualRadioButtonList control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RadioButtonList dualRadioButtonList;
|
||||
|
||||
/// <summary>
|
||||
/// objectTypePane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane objectTypePane;
|
||||
|
||||
/// <summary>
|
||||
/// PropertyPanel2 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel PropertyPanel2;
|
||||
|
||||
/// <summary>
|
||||
/// parentDropDownList control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList parentDropDownList;
|
||||
|
||||
/// <summary>
|
||||
/// PropertyPanel3 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel PropertyPanel3;
|
||||
|
||||
/// <summary>
|
||||
/// childDropDownList control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList childDropDownList;
|
||||
|
||||
/// <summary>
|
||||
/// addButton control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button addButton;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user