Skip to content

Commit

Permalink
New input option for Board widget (allowFieldBlanks)
Browse files Browse the repository at this point in the history
- Added new input option to the Board widget that allows
  override of whether items can be set to blank.
- Changed build 'deploy' target to first do a build.
  • Loading branch information
purtuga committed May 9, 2015
1 parent 6bc3ea0 commit 455de37
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ module.exports = function(grunt) {
},
test : {
src : ['test/**/*.js']
},
}
},

watch : {
Expand All @@ -490,7 +490,7 @@ module.exports = function(grunt) {
'test/**/*',
'*.aspx'
],
tasks : ['build', 'deploy']
tasks : ['deploy']
},
test : {
files : '<%= jshint.test.src %>',
Expand Down Expand Up @@ -627,7 +627,7 @@ module.exports = function(grunt) {
* BUILD
* Builds the appliation.
*/
grunt.registerTask('build', "Building Project...", function(){
grunt.registerTask('build', "jshint, test, build.", function(){

grunt.log.writeln("BUILD ID: " + buildId);
grunt.log.writeln("BUILD DIR: " + grunt.config(["copy", "build", "dest"]));
Expand Down Expand Up @@ -659,7 +659,7 @@ module.exports = function(grunt) {
* copy content from the build folder to the deploy destination.
*
*/
grunt.registerTask('deploy', ["copy:deploy"]);
grunt.registerTask('deploy', ["build", "copy:deploy"]);

grunt.registerTask('test', ["connect:test", "jasmine"]);

Expand Down
8 changes: 8 additions & 0 deletions documentation/SPWidgets.SPControlBoard.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This method takes as input an object containing the supported options:
CAMLViewFields: '',
fieldFilter: null,
optionalLabel: '(none)',
allowFieldBlanks: null,
template: null,
webURL: $().SPServices.SPGetCurrentSite(),
showColPicker: false,
Expand Down Expand Up @@ -152,6 +153,13 @@ The default options for this widget can be manipulated/set via the following obj
"</Query>"


- **allowFieldBlanks** : *Null|Boolean. Optional. Default=null* <br>
Controls whether an additional board state is shown that allows for items to be set to "none", which mean the value store for that Field is blank. By default, the Board widget will attempt to determine the correct behavior based on the Field List definition. Posisble values are:

- `null` : (Default). Widget will figure it out.
- `true` : Always show the "(none)" column. Note that if the field is setup as Required, updates to the item may fail.
- `false`: Always hide the "none" column, regardless of the field definition. Note that if your data has item with blanks for the field, those item will not be shown on the board.

- **optionalLabel** : *String. Optional. Default="(none)"* <br>
The string to be used as the State column header when field from where Board was built is optional in the List.

Expand Down
20 changes: 19 additions & 1 deletion src/boardWidget/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ define([
CAMLViewFields: '',
fieldFilter: null,
optionalLabel: '(none)',
allowFieldBlanks: null,
template: null,
webURL: '',
showColPicker: false,
Expand Down Expand Up @@ -91,6 +92,19 @@ define([
* be built from. This field should be either of type
* CHOICE or LOOKUP.
*
* @param {Null|Boolean} [options.allowFieldBlanks=null]
* Control whether an additional board state is shown that
* allows user to move a task to blank value (value in the column
* is blank). Possible values are:
* `null` - (default) widget will try to
* figure it out based on the Field definition in the list.
* `true` - Always show "none" column. Note that if the field is
* setup as Required, updates to the item may fail.
* `false` - Always hide the "none" column, regardless of the
* field definition. Note that if your data has item with blanks
* for the field, those item will not be shown on the board.
*
*
* @param {String|Function} [options.CAMLQuery="<Query></Query>"]
* String with CAML query to be used against the list
* to filter what is displayed or a function that will
Expand Down Expand Up @@ -517,9 +531,13 @@ define([

// store if field is required
if ( f.attr("Required") === "TRUE" ) {

opt.isStateRequired = true;
}

// Override the calculated required state attribute
// if user set allowFieldBlanks on input
if (typeof opt.allowFieldBlanks === "boolean") {
opt.isStateRequired = !opt.allowFieldBlanks;
}

switch(f.attr("Type").toLowerCase()) {
Expand Down

0 comments on commit 455de37

Please sign in to comment.