Skip to content

Commit

Permalink
Merge pull request #206 from maeisabelle/205-MinorLoadDataImprovements
Browse files Browse the repository at this point in the history
205 - Minor load data improvements
  • Loading branch information
paxtonhare committed Apr 15, 2016
2 parents 1c652a2 + 51223d4 commit 7e25503
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
34 changes: 34 additions & 0 deletions quick-start/src/main/resources/static/app/services/modalService.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
$scope.groups = jsonObj.groups;
//load previous settings to $scope.groups based on $scope.loadDataForm.otherOptions
updateGroupsBasedOnPreviousSettings($scope.groups, $scope.loadDataForm.otherOptions);
addReadOnlyLengthToGroupSettingWithDefaultValue($scope.groups);
})
.then(function () {
$scope.updateMlcpCommand();
Expand Down Expand Up @@ -222,6 +223,39 @@
return false;
};

$scope.makeDefaultValueReadOnlyIfApplicable = function($event) {
var elem = $event.currentTarget;
var readOnlyLengthData = elem.getAttribute("data-read-only-length");
if(readOnlyLengthData) {
var readOnlyLength = parseInt(readOnlyLengthData);
if (($event.which != 37 && ($event.which != 39))
&& ((elem.selectionStart < readOnlyLength)
|| ((elem.selectionStart === readOnlyLength) && ($event.which === 8)))) {
$event.preventDefault();
return false;
}
}
};
}

/*
* update $scope.groups and add a ReadOnlyLength
* for options with default value to disable removal of default value
* for options with type 'comma-list', set it to the length of the default value
* for options with type 'string', set it to -1 which means it should be readonly
*/
function addReadOnlyLengthToGroupSettingWithDefaultValue(groups) {
$.each(groups, function(i, group) {
$.each(group.settings, function(i, setting) {
if(setting.Value) {
if(setting.Type === 'comma-list') {
setting.ReadOnlyLength = setting.Value.length;
} else if(setting.Type === 'string') {
setting.ReadOnlyLength = -1;
}
}
});
});
}

function updateGroupsBasedOnPreviousSettings(groups, otherOptions) {
Expand Down
5 changes: 5 additions & 0 deletions quick-start/src/main/resources/static/css/quick-start.css
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ section {
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
}

.navbar-default {
background-color: #2a2d2b;
color: white;
}

/* This is specifically for Swagger UI */

.swagger-validator {
Expand Down
12 changes: 10 additions & 2 deletions quick-start/src/main/resources/static/top/modal/loadDataModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ <h4 class="modal-title" id="myModalLabel">Load Data</h4>
<div class="modal-body" id="myModalBody">
<div class="row">
<div id="details" class="col-xs-12 col-md-12">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<h4><i class="fa fa-info-circle"></i>Hover over the labels to view the description</h4>
</div>
</div>
</nav>
<form ng-submit="ok()">
<div class="form-group">
<label for="inputPath">Path</label>
Expand Down Expand Up @@ -38,8 +45,9 @@ <h4 class="modal-title" id="myModalLabel">Load Data</h4>
<uib-accordion-group heading="{{group.category}}" ng-repeat="group in groups" ng-show="showBasedOnCategoryAndInputFileType(group.category,loadDataForm.inputFileType)">
<div class="form-group" ng-repeat="setting in group.settings" ng-show="showIfHasNoFilterFieldOrWithSpecifiedValue(setting['FilterField'],setting['FilterValue'],group.settings)">
<input type="checkbox" name="{{setting['Field']}}" ng-if="setting['Type'] === 'boolean'" ng-model="setting['Value']" value="true" ng-change="updateMlcpCommand()" ng-focus="hideInputPathTreeBrowser()">
<label class="control-label" for="{{setting['Field']}}" title="{{setting['Description']}}">{{setting['Label']}}</label><br ng-if="setting['Type'] !== 'boolean'"/>
<input type="text" class="form-control" name="{{setting['Field']}}" ng-if="isText(setting['Type'])" ng-model="setting['Value']" placeholder="{{setting['Placeholder Value'] ? setting['Placeholder Value'] : ''}}" ng-change="updateMlcpCommand()" ng-focus="hideInputPathTreeBrowser()"/>
<label class="control-label" for="{{setting['Field']}}" popover-trigger="mouseenter" uib-popover="{{setting['Description']}}">{{setting['Label']}}</label><br ng-if="setting['Type'] !== 'boolean'"/>
<input type="text" class="form-control" name="{{setting['Field']}}" ng-if="isText(setting['Type'])" ng-model="setting['Value']" placeholder="{{setting['Placeholder Value'] ? setting['Placeholder Value'] : ''}}" ng-change="updateMlcpCommand()" ng-focus="hideInputPathTreeBrowser()"
data-read-only-length="{{setting['ReadOnlyLength']}}" ng-readonly="setting['ReadOnlyLength']===-1" ng-keypress="makeDefaultValueReadOnlyIfApplicable($event)" ng-keydown="makeDefaultValueReadOnlyIfApplicable($event)"/>
<select class="form-control" name="{{setting['Field']}}" ng-if="setting['Type'] === 'type'" ng-model="setting['Value']" ng-change="updateMlcpCommand()" ng-focus="hideInputPathTreeBrowser()">
<option ng-repeat="option in setting['Options']" value="{{option.value}}">{{option.label}}</option>
</select>
Expand Down

0 comments on commit 7e25503

Please sign in to comment.