-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SVY-10914 Mobile friendly web components
- Loading branch information
Showing
10 changed files
with
213 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
angular.module('bootstrapcomponentscommon',['servoy']).filter('showDisplayValue', function () { // filter that takes the realValue as an input and returns the displayValue | ||
return function (input, valuelist) { | ||
var i = 0; | ||
var realValue = input; | ||
if (valuelist) { | ||
if (input && input.hasOwnProperty("realValue")) { | ||
realValue = input.realValue; | ||
} | ||
//TODO performance upgrade: change the valuelist to a hashmap so that this for loop is no longer needed. | ||
//maybe to something like {realValue1:displayValue1, realValue2:displayValue2, ...} | ||
for (i = 0; i < valuelist.length; i++) { | ||
if (realValue === valuelist[i].realValue) { | ||
return getParsedDisplayValue(valuelist[i].displayValue); | ||
} | ||
} | ||
var hasRealValues = false; | ||
for (var i = 0; i < valuelist.length; i++) { | ||
var item = valuelist[i]; | ||
if (item.realValue != item.displayValue) { | ||
hasRealValues = true; | ||
break; | ||
} | ||
} | ||
if (hasRealValues) { | ||
var diplayValue = null; | ||
// this then function will resolve right away if the value is already cached on the client. | ||
valuelist.getDisplayValue(realValue).then(function(val){ | ||
diplayValue = val; | ||
}) | ||
return getParsedDisplayValue(diplayValue); | ||
} | ||
if (valuelist.length == 0) return null; | ||
} | ||
|
||
function getParsedDisplayValue(value) { | ||
if (value === undefined || value === null || value === '') { | ||
return ' ' | ||
} else { | ||
return value; | ||
} | ||
} | ||
|
||
return input; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.svy-wrapper > * > .bts-list { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.svy-wrapper > * > .bts-list input { | ||
height: 100%; | ||
padding: 0px 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class='bts-list'> | ||
<input | ||
svy-enter='handlers.onActionMethodID($event)' | ||
type="text" | ||
list="{{::model.svyMarkupId}}_datalist" | ||
ng-blur='onBlur($event)' | ||
ng-class='model.styleClass' | ||
ng-show='model.visible' | ||
ng-disabled="!model.enabled" | ||
sablo-tabseq='model.tabSeq' | ||
ng-readonly="model.readOnly || !model.editable" | ||
id="{{::model.svyMarkupId}}"/> | ||
|
||
<datalist id="{{::model.svyMarkupId}}_datalist"> | ||
<option ng-selected="model.dataProviderID === value.realValue" ng-repeat="value in model.valuelistID" | ||
value="{{value.realValue | showDisplayValue:model.valuelistID}}"> | ||
</option> | ||
</datalist> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
angular.module('bootstrapcomponentsList',['servoy', 'bootstrapcomponentscommon']).directive('bootstrapcomponentsList', ['$log', '$sabloConstants', '$filter', '$utils', function($log, $sabloConstants, $filter, $utils) { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
name: "=", | ||
model: "=svyModel", | ||
handlers: "=svyHandlers", | ||
api: "=svyApi", | ||
svyServoyapi: "=" | ||
}, | ||
link: function($scope, $element, $attrs) { | ||
var inputEl = $element.find('input'); | ||
|
||
function updateDataprovider() { | ||
var listValue = inputEl.val(); | ||
|
||
if($scope.model.valuelistID) { | ||
for (i = 0; i < $scope.model.valuelistID.length; i++) { | ||
if (listValue === $scope.model.valuelistID[i].displayValue) { | ||
listValue = $scope.model.valuelistID[i].realValue; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
$scope.model.dataProviderID = listValue; | ||
$scope.svyServoyapi.apply("dataProviderID"); | ||
} | ||
|
||
inputEl.on("keydown", function(event) { | ||
if($utils.testEnterKey(event)) { | ||
updateDataprovider(); | ||
} | ||
}); | ||
|
||
$scope.$watch('model.dataProviderID', function(newValue, oldValue) { | ||
var listValue = newValue; | ||
|
||
if($scope.model.valuelistID) { | ||
var showDisplayValueFilter = $filter("showDisplayValue"); | ||
var displayValue = showDisplayValueFilter(listValue, $scope.model.valuelistID); | ||
if(displayValue !== ' ') { | ||
listValue = displayValue; | ||
} | ||
} | ||
|
||
inputEl.val(listValue); | ||
}) | ||
|
||
$scope.onBlur = function(event) { | ||
updateDataprovider(); | ||
} | ||
|
||
/** | ||
* Set the focus to the list input | ||
* @example %%prefix%%%%elementName%%.requestFocus(); | ||
*/ | ||
$scope.api.requestFocus = function() { | ||
inputEl[0].focus(); | ||
} | ||
}, | ||
templateUrl: 'bootstrapcomponents/list/list.html' | ||
}; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "bootstrapcomponents-list", | ||
"displayName": "Data List", | ||
"version": 1, | ||
"icon": "servoydefault/typeahead/bhdropdownlisticon.gif", | ||
"definition": "bootstrapcomponents/list/list.js", | ||
"libraries": [{"name":"bootstrapcomponents-list-css", "version":"1.0", "url":"bootstrapcomponents/list/list.css", "mimetype":"text/css"}], | ||
"model": | ||
{ | ||
"dataProviderID" : { "type":"dataprovider","pushToServer": "allow", "tags": { "scope" :"design" }, "ondatachange": { "onchange":"onDataChangeMethodID", "callback":"onDataChangeCallback"}}, | ||
"enabled" : { "type": "enabled", "blockingOn": false, "default": true, "for": ["dataProviderID","onActionMethodID","onDataChangeMethodID"] }, | ||
"readOnly" : { "type": "protected", "blockingOn": true, "default": false,"for": ["dataProviderID","onDataChangeMethodID"], "tags": {"scope":"runtime"} }, | ||
"editable" : { "type": "protected", "blockingOn": false, "default": true,"for": ["dataProviderID","onDataChangeMethodID"] }, | ||
"styleClass" : { "type" :"styleclass", "tags": { "scope" :"design" }, "default" : "form-control"}, | ||
"valuelistID" : { "type" : "valuelist", "tags": { "scope" :"design" }, "for": "dataProviderID"}, | ||
"tabSeq" : {"type" :"tabseq", "tags": { "scope" :"design" }}, | ||
"visible" : "visible" | ||
}, | ||
"handlers": | ||
{ | ||
"onActionMethodID" : { | ||
|
||
"parameters":[ | ||
{ | ||
"name":"event", | ||
"type":"JSEvent" | ||
} | ||
] | ||
}, | ||
"onDataChangeMethodID" : { | ||
"returns": "boolean", | ||
|
||
"parameters":[ | ||
{ | ||
"name":"oldValue", | ||
"type":"${dataproviderType}" | ||
}, | ||
{ | ||
"name":"newValue", | ||
"type":"${dataproviderType}" | ||
}, | ||
{ | ||
"name":"event", | ||
"type":"JSEvent" | ||
} | ||
] | ||
} | ||
}, | ||
"api": | ||
{ | ||
"requestFocus": { | ||
"delayUntilFormLoads": true, | ||
"discardPreviouslyQueuedSimilarCalls": true | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters