Skip to content

Commit d0ce42f

Browse files
committed
Merge pull request #14 from dougludlow/emptytitle
Use url as name when Page Title is left empty
2 parents 4b6f199 + cf9c8fe commit d0ce42f

File tree

3 files changed

+50
-19
lines changed

3 files changed

+50
-19
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ module.exports = function (grunt) {
3333
nuget: {
3434
expand: true,
3535
cwd: '<%= basePath %>',
36-
src: '**',
36+
src: '<%= basePath %>',
3737
dest: 'tmp/nuget/content/'
3838
},
3939

4040
umbraco: {
4141
expand: true,
4242
cwd: '<%= basePath %>/',
43-
src: '**',
43+
src: '<%= basePath %>',
4444
dest: 'tmp/umbraco/'
4545
},
4646

src/RJP.MultiUrlPicker/App_Plugins/RJP.MultiUrlPicker/MultiUrlPicker.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ angular.module("umbraco").controller("RJP.MultiUrlPickerController", function($s
1010

1111
if( $scope.model.value ) {
1212
_.each($scope.model.value, function( item, i ) {
13-
$scope.renderModel.push({
14-
name: item.name
15-
, id: item.id
16-
, url: item.url
17-
, target: item.target
18-
, isMedia: item.isMedia
19-
, icon: item.icon || 'icon-link'
20-
})
13+
$scope.renderModel.push(new Link(item))
2114
if( item.id ) {
2215
(item.isMedia ? mediaIds : documentIds).push( item.id )
2316
}
@@ -107,14 +100,7 @@ angular.module("umbraco").controller("RJP.MultiUrlPickerController", function($s
107100

108101

109102
$scope.onContentSelected = function(e) {
110-
var link = {
111-
id: e.id
112-
, name: e.name
113-
, url: e.url
114-
, target: e.target
115-
, isMedia: e.isMedia
116-
, icon: 'icon-link'
117-
}
103+
var link = new Link(e);
118104

119105
if( e.index != null ) {
120106
$scope.renderModel[ e.index ] = link
@@ -129,4 +115,13 @@ angular.module("umbraco").controller("RJP.MultiUrlPickerController", function($s
129115
$scope.model.value = $scope.renderModel
130116
dialogService.closeAll()
131117
}
118+
119+
function Link(link) {
120+
this.id = link.id;
121+
this.name = link.name || link.url;
122+
this.url = link.url;
123+
this.target = link.target;
124+
this.isMedia = link.isMedia;
125+
this.icon = link.icon || 'icon-link';
126+
}
132127
})

src/RJP.MultiUrlPicker/test/spec/MultiUrlPickerController.spec.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe('RJP.MultiUrlPickerController', function () {
2727
}));
2828

2929
it("doesn't try to get entity when id is less than 1", inject(function ($q, entityResource) {
30-
3130
var e = {
3231
id: -20,
3332
name: 'Recycle Bin',
@@ -51,4 +50,41 @@ describe('RJP.MultiUrlPickerController', function () {
5150

5251
expect(entityResource.getById).not.toHaveBeenCalled();
5352
}));
53+
54+
it('uses the url if the Page Title field is left empty', function () {
55+
var e = {
56+
id: null,
57+
name: '',
58+
url: 'http://www.google.com/',
59+
isMedia: false,
60+
icon: ''
61+
};
62+
63+
createController();
64+
65+
expect($scope.renderModel.length).toBe(0);
66+
67+
$scope.onContentSelected(e);
68+
69+
expect($scope.renderModel.length).toBe(1);
70+
expect($scope.renderModel[0].name).toBe(e.url);
71+
});
72+
73+
it('shows the url is name is empty when loaded from the database', function () {
74+
75+
var link = {
76+
id: 1,
77+
name: '',
78+
url: 'http://www.google.com/',
79+
isMedia: false,
80+
icon: 'icon-link'
81+
};
82+
83+
$scope.model.value = [link];
84+
85+
createController();
86+
87+
expect($scope.renderModel.length).toBe(1);
88+
expect($scope.renderModel[0].name).toBe(link.url);
89+
})
5490
});

0 commit comments

Comments
 (0)