Skip to content
This repository was archived by the owner on Oct 11, 2018. It is now read-only.

Better Fix for users/groups selector. #720

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Expand Up @@ -33,9 +33,7 @@
"disabled": {"<-": "@owner.disabled"},
"controller": {"<-": "@owner.controller"},
"initialOptions": {"<-": "@owner.initialOptions"},
"labelExpression": {"<-": "@owner.labelExpression"},
"labelPath": {"<-": "@owner.labelPath"},
"valuePath": {"<-": "@owner.valuePath"},
"values": {"<->": "@owner.values"}
}
}
Expand Down
2 changes: 0 additions & 2 deletions blue-shark/ui/field-search.reel/field-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
"disabled": {"<-": "@owner.disabled"},
"controller": {"<-": "@owner.controller"},
"labelPath": {"<-": "@owner.labelPath"},
"labelExpression": {"<-": "@owner.labelExpression"},
"valuePath": {"<-": "@owner.valuePath"},
"initialOptions": {"<-": "@owner.initialOptions"},
"hasNoneButton": {"<-": "@owner.hasNoneButton"},
"value": {"<->": "@owner.value"}
Expand Down
2 changes: 1 addition & 1 deletion blue-shark/ui/search-multiple.reel/search-multiple.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"element": {"#": "select"}
},
"bindings": {
"options": {"<-": "@owner._results.map{{label: this.path(@owner.labelPath), value: this.path(@owner.valuePath)}}"}
"options": {"<-": "@owner._results.map{{label: this.path(@owner.labelPath), value: this.path(@owner.labelPath)}}"}
}
},

Expand Down
2 changes: 1 addition & 1 deletion blue-shark/ui/search-multiple.reel/search-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.SearchMultiple = Search.specialize(/** @lends SearchMultiple# */ {
_.concat(this.values || [],
_.difference(this._results,
_.differenceWith(this._results, this._selectComponent.selectedValues, function (object, value) {
return object[self.valuePath] === value;
return object[self.labelPath] === value;
})
)
)
Expand Down
2 changes: 1 addition & 1 deletion blue-shark/ui/search.reel/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"allowMultiple": false
},
"bindings": {
"options": {"<-": "@owner._results.map{{label: this.path(@owner.labelPath), value: this.path(@owner.valuePath)}}"}
"options": {"<-": "@owner._results.map{{label: this.path(@owner.labelPath), value: this.path(@owner.labelPath)}}"}
}
},

Expand Down
7 changes: 4 additions & 3 deletions blue-shark/ui/search.reel/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ exports.Search = Component.specialize(/** @lends Search# */ {

value: {
set: function (value) {
this._value = value ? this.valuePath ? value[this.valuePath] || value : value : null;
this.displayedValue = value ? this.labelPath ? value[this.labelPath] || value : value : 'none';
this._value = value;
this.displayedValue = value ? this.labelPath ?
value[this.labelPath] || (typeof value === 'string' ? value : 'none') : value : 'none';
},
get: function () {
return this._value;
Expand Down Expand Up @@ -68,7 +69,7 @@ exports.Search = Component.specialize(/** @lends Search# */ {
selectedValue = this._selectComponent.selectedValues[0];

this.value = _.find(this._results, function (result) {
return result[self.valuePath] === selectedValue;
return result[self.labelPath] === selectedValue;
});
}

Expand Down
19 changes: 0 additions & 19 deletions ui/abstract/abstract-search-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,6 @@ exports.AbstractSearchAccount = Component.specialize({
}
},

_valuePath: {
value: null
},

valuePath: {
set: function (path) {
if (this._valuePath !== path) {
if (typeof path === "string" && path.length) {
this._valuePath = path;
} else {
this._valuePath = null;
}
}
},
get: function () {
return this._valuePath || this.constructor.valuePath;
}
},

_isLoading: {
value: null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"initialOptions": {"<-": "@owner.initialOptions"},
"hasNoneButton": {"<-": "@owner.hasNoneButton"},
"labelPath": {"<-": "@owner.labelPath"},
"valuePath": {"<-": "@owner.valuePath"},
"validationPath": {"<-": "@owner.validationPath"}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ exports.SearchGroupsMultiple = AbstractSearchAccountMultiple.specialize(/** @len

labelPath: {
value: 'name'
},

valuePath: {
value: 'id'
}

});
Expand Down
1 change: 0 additions & 1 deletion ui/controls/search-groups.reel/search-groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"bindings": {
"value": {"<->": "@owner.value"},
"labelPath": {"<-": "@owner.labelPath"},
"valuePath": {"<-": "@owner.valuePath"},
"label": {"<-": "@owner.label"},
"disabled": {"<-": "@owner.disabled"},
"isLoading": {"<-": "@owner.isLoading"},
Expand Down
4 changes: 0 additions & 4 deletions ui/controls/search-groups.reel/search-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ exports.SearchGroups = AbstractSearchAccount.specialize(/** @lends SearchGroups#

labelPath: {
value: 'name'
},

valuePath: {
value: 'id'
}

});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"initialOptions": {"<-": "@owner.initialOptions"},
"hasNoneButton": {"<-": "@owner.hasNoneButton"},
"labelPath": {"<-": "@owner.labelPath"},
"valuePath": {"<-": "@owner.valuePath"},
"validationPath": {"<-": "@owner.validationPath"}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ exports.SearchUsersMultiple = AbstractSearchAccountMultiple.specialize(/** @lend

labelPath: {
value: 'username'
},

valuePath: {
value: 'id'
}

});
1 change: 0 additions & 1 deletion ui/controls/search-users.reel/search-users.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"disabled": {"<-": "@owner.disabled"},
"isLoading": {"<-": "@owner.isLoading"},
"labelPath": {"<-": "@owner.labelPath"},
"valuePath": {"<-": "@owner.valuePath"},
"initialOptions": {"<-": "@owner.initialOptions"},
"validationPath": {"<-": "@owner.validationPath"},
"hasNoneButton": {"<-": "@owner.hasNoneButton"}
Expand Down
4 changes: 0 additions & 4 deletions ui/controls/search-users.reel/search-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ exports.SearchUsers = AbstractSearchAccount.specialize(/** @lends SearchGroups#

labelPath: {
value: 'username'
},

valuePath: {
value: 'id'
}

});
1 change: 1 addition & 0 deletions ui/inspectors/calendar-task.reel/calendar-task.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"bindings": {
"moduleId": {"<-": "'ui/inspectors/calendar-task.reel/' + @owner.taskToInspector[@owner.object.task] + '-args.reel'"},
"object": {"<->": "@owner.object.args"},
"context": {"<->": "@owner.context"},
"component.isNew": {"<-": "@owner.object._isNew"}
}
},
Expand Down
48 changes: 32 additions & 16 deletions ui/inspectors/calendar-task.reel/calendar-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,8 @@ exports.CalendarTask = AbstractInspector.specialize({
this._sectionService.updateScheduleOnTask(this.object);
delete this.object.status;

var argsPromise = this.object.args;
if (this.argsInspector && typeof this.argsInspector.save === 'function') {
argsPromise = this.argsInspector.save(this.object);
}
argsPromise = Promise.is(argsPromise) ? argsPromise : this.resolveArgs(argsPromise);

var self = this;
return argsPromise.then(function(args) {
self.object.args = args;
return this._saveCalendarTaskArgs().then(function () {
return self.inspector.save();
});
}
Expand All @@ -117,15 +110,9 @@ exports.CalendarTask = AbstractInspector.specialize({

handleRunNowAction: {
value: function () {
var argsPromise = this.object.args;
if (this.argsInspector && typeof this.argsInspector.save === 'function') {
argsPromise = this.argsInspector.save(this.object);
}
var self = this,
argsPromise = Promise.is(argsPromise) ? argsPromise : Promise.resolve(argsPromise);
var self = this;

return argsPromise.then(function(args) {
self.object.args = args;
return this._saveCalendarTaskArgs().then(function () {
return self._sectionService.runTask(self.object);
});
}
Expand All @@ -141,6 +128,35 @@ exports.CalendarTask = AbstractInspector.specialize({
}
},

_saveCalendarTaskArgs: {
value: function () {
var args = this._prepareCalendarTaskArgs(),
self = this;

if (this.argsInspector && typeof this.argsInspector.save === 'function') {
args = this.argsInspector.save(this.object);
}

return (Promise.is(args) ? args : Promise.resolve(args)).then(function (args) {
self.object.args = args;
});
}
},

_prepareCalendarTaskArgs: {
value: function () {
var args = this.object.args;

if (this.taskToInspector[this.object.task] === 'cron') {
args[0] = this.context.cronUser.username;
} else if (this.taskToInspector[this.object.task] === 'rsync' && args[0]) {
args[0].user = this.context.rsyncUser.username;
}

return args;
}
},

_handleSimpleScheduleChange: {
value: function() {
this.scheduleString = this._sectionService.getScheduleStringForTask(this.object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"owner": {
"properties": {
"element": {"#": "owner"}
},
"bindings": {
"context.cronUser": {"<-": "@owner.object.0.{username: this}"}
}
},
"command": {
Expand All @@ -24,11 +27,10 @@
"prototype": "ui/controls/search-users.reel",
"properties": {
"element": {"#": "user"},
"label": "User",
"valuePath": "username"
"label": "User"
},
"bindings": {
"value": {"<->": "@owner.object.0"}
"value": {"<->": "@owner.context.cronUser"}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"owner": {
"properties": {
"element": {"#": "owner"}
},
"bindings": {
"context.rsyncUser": {"<-": "@owner.object.0.user.{username: this}"}
}
},
"mode": {
Expand Down Expand Up @@ -36,11 +39,10 @@
"prototype": "ui/controls/search-users.reel",
"properties": {
"element": {"#": "user"},
"label": "User",
"valuePath": "username"
"label": "User"
},
"bindings": {
"value": {"<->": "@owner.object.0.user"}
"value": {"<->": "@owner.context.rsyncUser"}
}
},
"path": {
Expand Down
8 changes: 5 additions & 3 deletions ui/inspectors/service.reel/afp-service.reel/afp-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"owner": {
"properties": {
"element": {"#": "owner"}
},
"bindings": {
"context.guestUser": {"<-": "@owner.object.guest_user.{username: this}"}
}
},
"positiveIntegerValidator": {
Expand Down Expand Up @@ -71,11 +74,10 @@
"prototype": "ui/controls/search-users.reel",
"properties": {
"element": {"#": "guest_user"},
"label": "Guest User",
"valuePath": "username"
"label": "Guest User"
},
"bindings": {
"value": {"<->": "@owner.object.guest_user"}
"value": {"<->": "@owner.context.guestUser"}
}
},
"homedir_path": {
Expand Down
5 changes: 5 additions & 0 deletions ui/inspectors/service.reel/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ exports.Service = AbstractInspector.specialize({
if (this.configComponent && typeof this.configComponent.save === 'function') {
this.configComponent.save();
}

if (this.name === 'afp' || this.name === 'smb') {
this.object.config.guest_user = this.context.guestUser.username;
}

this._sectionService.saveService(this.object);
}
},
Expand Down
8 changes: 5 additions & 3 deletions ui/inspectors/service.reel/smb-service.reel/smb-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"owner": {
"properties": {
"element": {"#": "owner"}
},
"bindings": {
"context.guestUser": {"<-": "@owner.object.guest_user.{username: this}"}
}
},
"netbiosName": {
Expand Down Expand Up @@ -107,11 +110,10 @@
"prototype": "ui/controls/search-users.reel",
"properties": {
"element": {"#": "guestUser"},
"label": "Guest account",
"valuePath": "username"
"label": "Guest account"
},
"bindings": {
"value": {"<->": "@owner.object.guest_user"}
"value": {"<->": "@owner.context.guestUser"}
}
},
"fileMask": {
Expand Down
3 changes: 1 addition & 2 deletions ui/sections/accounts/inspectors/user.reel/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ exports.User = AbstractInspector.specialize({
delete this.object.home;
}

this.object.group = this.context.primaryGroup ? this.context.primaryGroup : null;
this.object.group = this.object.group && typeof this.object.group === 'object' ? this.object.group.id : this.object.group;
this.object.group = this.context.primaryGroup ? this.context.primaryGroup.id : null;
this.object.groups = this.context.secondaryGroups ? this.context.secondaryGroups.map(function (groups) {
return groups.id;
}, this) : null;
Expand Down
Loading