Skip to content
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

[WIP] Add domains dialog #7

Merged
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
@@ -1,12 +1,13 @@
(function () {
'use strict';

function controller(domainResource, notificationsService, overlayService, localizationService, eventsService) {
function controller(domainResource, editorService, notificationsService, overlayService, localizationService, eventsService) {

var vm = this;
vm.page = {};
vm.domains = [];

vm.addDomain = addDomain;
vm.deleteDomain = deleteDomain;
vm.navigate = navigate;

Expand All @@ -19,6 +20,21 @@
loadDomains();
}

function addDomain() {
var dialog = {
view: "/App_Plugins/domains/backoffice/domains/overlays/create.html",
size: "small",
submit: function (model) {
editorService.close();
},
close: function () {
editorService.close();
}
};

editorService.open(dialog);
}

function deleteDomain(domain, event) {
console.log(domain);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@

<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>

<umb-editor-sub-header>

<umb-editor-sub-header-content-right>
<umb-button type="button"
button-style="info"
action="vm.addDomain()"
label="Add domain">
</umb-button>
</umb-editor-sub-header-content-right>

</umb-editor-sub-header>

<table class="table table-hover" ng-if="!vm.loading">
<thead>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
(function () {
'use strict';

function CreateDomainController($scope, languageResource, contentResource) {

var vm = this;

vm.languages = [];

vm.hostname = null;
vm.node = null;
vm.language = null;

vm.save = save;
vm.close = close;

vm.dialogTreeApi = {};

vm.onTreeInit = function () {
vm.dialogTreeApi.callbacks.treeNodeSelect(nodeSelectHandler);
};

function nodeSelectHandler(args) {
if (args && args.event) {
args.event.preventDefault();
args.event.stopPropagation();
}

if (vm.node) {
//un-select if there's a current one selected
vm.node.selected = false;
}

vm.node = args.node;
vm.node.selected = true;
};

function save() {
var data = {
nodeId: vm.node.id,
domains: [
{
name: vm.hostname,
lang: vm.language.id
}
]
};

contentResource.saveLanguageAndDomains(data)
.then(function (response) {
if (!response.valid) {
alert('Oops!');
} else {
$scope.model.submit();
}
});
};

function close() {
$scope.model.close();
};

function init() {
languageResource.getAll()
.then(function (languages) {
vm.languages = languages;
});
};

init();

}

angular.module('umbraco')
.controller('Domains.Overlays.CreateController', CreateDomainController);
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<div ng-controller="Domains.Overlays.CreateController as vm" class="form-horizontal">

<umb-editor-view>

<umb-editor-header name="'Add Domain'"
name-locked="true"
hide-alias="true"
hide-icon="true"
hide-description="true">
</umb-editor-header>

<umb-editor-container>
<umb-box>
<umb-box-content>

<umb-control-group label="Hostname">
<input type="text"
class="umb-property-editor umb-textstring"
ng-model="vm.hostname" />
</umb-control-group>

<umb-control-group label="Node">
<umb-tree section="content"
hideheader="true"
hideoptions="true"
api="vm.dialogTreeApi"
on-init="vm.onTreeInit()"
enablelistviewexpand="true"
isdialog="true"
enablecheckboxes="true">
</umb-tree>
</umb-control-group>

<umb-control-group label="Language">
<select name="language"
ng-model="vm.language"
ng-options="lang.name for lang in vm.languages"
required>
</select>
</umb-control-group>

</umb-box-content>
</umb-box>
</umb-editor-container>

<umb-editor-footer>
<umb-editor-footer-content-right>
<umb-button type="button"
button-style="link"
label-key="general_close"
shortcut="esc"
action="vm.close()">
</umb-button>

<umb-button type="button"
button-style="action"
label-key="general_submit"
action="vm.save()">
</umb-button>
</umb-editor-footer-content-right>
</umb-editor-footer>

</umb-editor-view>

</div>
3 changes: 2 additions & 1 deletion Our.Umbraco.Domains/App_Plugins/domains/package.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

"javascript": [

//Controllers
//Controllers
"~/App_Plugins/domains/backoffice/domains/dashboard.controller.js",
"~/App_Plugins/domains/backoffice/domains/overlays/create.controller.js",

//Resources
"~/App_Plugins/domains/resources/domain.resource.js"
Expand Down