From e7dc403ddc27082d561f4e69fc5337a100509ebf Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Sun, 26 Feb 2017 15:48:12 +0100 Subject: [PATCH] [TASK] [web] switch model url binding --- public/app/web/list.jade | 8 +++++--- public/app/web/page.jade | 10 ++++------ public/app/web/page.js | 9 +++------ public/app/web/webmenu.jade | 8 +++++--- public/app/web/webmenu.js | 19 +++++++++++++++---- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/public/app/web/list.jade b/public/app/web/list.jade index efaad96..918237c 100644 --- a/public/app/web/list.jade +++ b/public/app/web/list.jade @@ -15,10 +15,13 @@ td(data-title="'#'") {{item.website.ID}} td(data-title="'Name'") span(ng-if="!item.isEditing") {{item.website.name}} - form(name="myform",ng-if="item.isEditing") + form(name="myform",ng-if="item.isEditing",ng-submit="edit(item)") .form-group(ng-class="{'has-error': (error.fields.indexOf('name') >= 0 || !myform.name.$valid)}") label(for="name") Name input.form-control(id="name",name="name",ng-model="item.website.name") + button.btn.btn-primary(type="submit") + span.glyphicon.glyphicon-floppy-disk + | Save td(data-title="'Option'") .btn-group.btn-group-xs a.btn.btn-default(ui-sref="app.webS.page({websiteid:item.website.ID})") @@ -26,7 +29,6 @@ span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing") span.glyphicon.glyphicon-pencil span.btn.btn-default(ng-click="edit(item)",ng-if="item.isEditing") - span.glyphicon.glyphicon-remove-circle + span.glyphicon.glyphicon-floppy-disk span.btn.btn-default(ng-click="delete(item)") span.glyphicon.glyphicon-trash - diff --git a/public/app/web/page.jade b/public/app/web/page.jade index 06ac3bd..ac65c58 100644 --- a/public/app/web/page.jade +++ b/public/app/web/page.jade @@ -22,12 +22,10 @@ label(for="title") Title input.form-control(id="title",ng-model="obj.title") .form-group - label Under Menu - i (http(s)://PLACEHOLDER/{{obj.menu.url}}) - ui-select(ng-model="obj.menu",theme="bootstrap") - ui-select-match {{$select.selected.name}} - ui-select-choices(repeat="item in menulist | filter:$select.search") - div(ng-bind-html="item.name | highlight: $select.search") + label(for="url") URL + br + i (http(s)://DOMAIN/{{obj.url.path}}) + input.form-control(id="url",ng-model="obj.url.path") .form-group label(for="content") Content textarea.form-control(id="content",markdown-editor="{hiddenButtons:'cmdImage',addExtraButtons: true, resize: 'vertical'}",ng-model="obj.content",rows="10") diff --git a/public/app/web/page.js b/public/app/web/page.js index 9184e7a..6b9a897 100644 --- a/public/app/web/page.js +++ b/public/app/web/page.js @@ -11,12 +11,9 @@ angular.module('warehost') $scope.obj = {}; } function load(){ - $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu/list').then(function(res){ - $scope.menulist = res.data.data; - $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/page').then(function(res){ - session.set(res); - $scope.data = res.data.data; - }); + $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/page').then(function(res){ + session.set(res); + $scope.data = res.data.data; }); } function submitresult(res){ diff --git a/public/app/web/webmenu.jade b/public/app/web/webmenu.jade index c72b373..5edee0c 100644 --- a/public/app/web/webmenu.jade +++ b/public/app/web/webmenu.jade @@ -38,7 +38,9 @@ script#nodes_renderer(type="text/ng-template") label(for="name") Name input.form-control(id="name",ng-model="obj.name") .form-group - label(for="shortUrl") URL - i (http(s)://PLACEHOLDER/{{obj.url}}) - input.form-control(id="shortUrl",ng-model="obj.url") + label Link to: + ui-select(ng-model="obj.url",theme="bootstrap") + ui-select-match http(s)://DOMAIN/{{$select.selected.path}} + ui-select-choices(repeat="item in urllist | filter:$select.search") + div {{item.type.toUpperCase()}}: http(s)://DOMAIN/{{ item.path }} input.btn.btn-default(type="submit",value="Save") diff --git a/public/app/web/webmenu.js b/public/app/web/webmenu.js index de34eff..d5bc233 100644 --- a/public/app/web/webmenu.js +++ b/public/app/web/webmenu.js @@ -3,6 +3,7 @@ angular.module('warehost') .controller('WebmenuWebCtrl',function(session,config,alert,$scope,$rootScope,$stateParams,$http){ $scope.data = []; + $scope.urllist = []; alert.set({}); $scope.treeOptions = { @@ -24,10 +25,20 @@ angular.module('warehost') } }; - function load(){ - $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu').then(function(res){ - session.set(res); - $scope.data = res.data.data; + function load() { + $scope.urllist = []; + $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/page').then(function(res){ + res.data.data.forEach(function (d) { + var url = d.url; + url.type = 'page'; + url.obj = d; + url.obj.url = null; + $scope.urllist.push(url); + }); + $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu').then(function(res){ + session.set(res); + $scope.data = res.data.data; + }); }); } function submitresult(res){