custom fields on all add/edit login pages

This commit is contained in:
Kyle Spearrin 2017-09-21 14:27:07 -04:00
parent 8fa6ff48cf
commit 05c8a39e6d
6 changed files with 132 additions and 10 deletions

View File

@ -30,6 +30,25 @@
} }
}; };
$scope.addField = function () {
if (!$scope.login.fields) {
$scope.login.fields = [];
}
$scope.login.fields.push({
type: '0',
name: null,
value: null
});
}
$scope.removeField = function (field) {
var index = $scope.login.fields.indexOf(field);
if (index > -1) {
$scope.login.fields.splice(index, 1);
}
}
$scope.clipboardSuccess = function (e) { $scope.clipboardSuccess = function (e) {
e.clearSelection(); e.clearSelection();
selectPassword(e); selectPassword(e);

View File

@ -31,6 +31,25 @@
} }
}; };
$scope.addField = function () {
if (!$scope.login.fields) {
$scope.login.fields = [];
}
$scope.login.fields.push({
type: '0',
name: null,
value: null
});
}
$scope.removeField = function (field) {
var index = $scope.login.fields.indexOf(field);
if (index > -1) {
$scope.login.fields.splice(index, 1);
}
}
$scope.clipboardSuccess = function (e) { $scope.clipboardSuccess = function (e) {
e.clearSelection(); e.clearSelection();
selectPassword(e); selectPassword(e);

View File

@ -31,6 +31,29 @@
} }
}; };
$scope.addField = function () {
if (!$scope.login.fields) {
$scope.login.fields = [];
}
$scope.login.fields.push({
type: '0',
name: null,
value: null
});
}
$scope.removeField = function (field) {
var index = $scope.login.fields.indexOf(field);
if (index > -1) {
$scope.login.fields.splice(index, 1);
}
}
$scope.toggleFavorite = function () {
$scope.login.favorite = !$scope.login.favorite;
}
$scope.clipboardSuccess = function (e) { $scope.clipboardSuccess = function (e) {
e.clearSelection(); e.clearSelection();
selectPassword(e); selectPassword(e);

View File

@ -55,8 +55,12 @@
}; };
$scope.addField = function () { $scope.addField = function () {
if (!$scope.login.fields) {
$scope.login.fields = [];
}
$scope.login.fields.push({ $scope.login.fields.push({
type: 0, type: '0',
name: null, name: null,
value: null value: null
}); });

View File

@ -99,17 +99,73 @@
<label for="notes">Notes</label> <label for="notes">Notes</label>
<textarea id="notes" name="Notes" class="form-control" ng-model="login.notes" api-field></textarea> <textarea id="notes" name="Notes" class="form-control" ng-model="login.notes" api-field></textarea>
</div> </div>
<div class="checkbox" ng-if="!hideFavorite"> <hr />
<label> <h4><i class="fa fa-list-ul"></i> Custom Fields</h4>
<input type="checkbox" ng-model="login.favorite" name="Favorite" /> <div ng-repeat="field in login.fields">
Favorite <div class="row">
</label> <div class="col-sm-3">
<div class="form-group">
<label for="field_name{{$index}}">Name</label>
<input type="text" id="field_name{{$index}}" name="Field.Name{{$index}}" class="form-control" ng-model="field.name" />
</div> </div>
</div> </div>
<div class="col-sm-3">
<div class="form-group">
<label for="field_type{{$index}}">Type</label>
<select id="field_type{{$index}}" name="Field.Type{{$index}}" class="form-control" ng-model="field.type">
<option value="0">Text</option>
<option value="1">Hidden</option>
<option value="2">Boolean</option>
</select>
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<div class="pull-right password-options" ng-if="field.type === '1'">
<i class="fa fa-lg fa-eye" uib-tooltip="Toggle Visibility" tooltip-placement="left"
password-viewer="#field_value{{$index}}"></i>
</div>
<label for="field_value{{$index}}">Value</label>
<div class="input-group" ng-if="field.type !== '2'">
<input ng-attr-type="{{field.type === '0' ? 'text' : 'password'}}" id="field_value{{$index}}"
name="Field.Value{{$index}}" class="form-control" ng-model="field.value" />
<span class="input-group-btn" uib-tooltip="Copy Value" tooltip-placement="left">
<button class="btn btn-default btn-flat" type="button" ngclipboard
ngclipboard-success="clipboardSuccess(e)" ngclipboard-error="clipboardError(e, true)"
data-clipboard-text="{{field.value}}">
<i class="fa fa-clipboard"></i>
</button>
</span>
</div>
<div ng-if="field.type === '2'">
<input type="checkbox" id="field_value{{$index}}" name="Field.Value{{$index}}" ng-model="field.value"
data-ng-true-value="'true'" />
</div>
</div>
</div>
<div class="col-md-1">
<br class="hidden-xs" />
<a href="#" ng-click="removeField(field)" stop-click>
<i class="fa fa-remove"></i>
<span class="visible-xs-inline">Remove Custom Field</span>
</a>
</div>
</div>
<hr class="visible-xs-block" />
</div>
<a href="#" ng-click="addField()" stop-click>
<i class="fa fa-plus-circle"></i> New Custom Field
</a>
</div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="addLoginForm.$loading"> <button type="submit" class="btn btn-primary btn-flat" ng-disabled="addLoginForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="addLoginForm.$loading"></i>Submit <i class="fa fa-refresh fa-spin loading-icon" ng-show="addLoginForm.$loading"></i>Submit
</button> </button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button> <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
<button type="button" ng-if="!hideFavorite" class="btn btn-link pull-right" ng-click="toggleFavorite()"
uib-tooltip="Toggle Favorite" tooltip-placement="left">
<i class="fa fa-lg" ng-class="login.favorite ? 'fa-star' : 'fa-star-o'"></i>
<span class="sr-only">Toggle Favorite</span>
</button>
</div> </div>
</form> </form>

View File

@ -158,7 +158,7 @@
</div> </div>
<div class="col-md-1"> <div class="col-md-1">
<br class="hidden-xs" /> <br class="hidden-xs" />
<a href="#" ng-click="removeField(field)"> <a href="#" ng-click="removeField(field)" stop-click>
<i class="fa fa-remove"></i> <i class="fa fa-remove"></i>
<span class="visible-xs-inline">Remove Custom Field</span> <span class="visible-xs-inline">Remove Custom Field</span>
</a> </a>
@ -166,7 +166,7 @@
</div> </div>
<hr class="visible-xs-block" /> <hr class="visible-xs-block" />
</div> </div>
<a href="#" ng-click="addField()"> <a href="#" ng-click="addField()" stop-click>
<i class="fa fa-plus-circle"></i> New Custom Field <i class="fa fa-plus-circle"></i> New Custom Field
</a> </a>
</div> </div>
@ -175,12 +175,13 @@
<i class="fa fa-refresh fa-spin loading-icon" ng-show="editLoginForm.$loading"></i>Save <i class="fa fa-refresh fa-spin loading-icon" ng-show="editLoginForm.$loading"></i>Save
</button> </button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button> <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
<button type="button" class="btn btn-link pull-right" ng-click="delete()" uib-tooltip="Delete" ng-disabled="readOnly"> <button type="button" class="btn btn-link pull-right" ng-click="delete()" uib-tooltip="Delete"
tooltip-placement="left" ng-disabled="readOnly">
<i class="fa fa-trash fa-lg"></i> <i class="fa fa-trash fa-lg"></i>
<span class="sr-only">Delete</span> <span class="sr-only">Delete</span>
</button> </button>
<button type="button" ng-if="!hideFavorite" class="btn btn-link pull-right" ng-click="toggleFavorite()" <button type="button" ng-if="!hideFavorite" class="btn btn-link pull-right" ng-click="toggleFavorite()"
uib-tooltip="Toggle Favorite"> uib-tooltip="Toggle Favorite" tooltip-placement="left">
<i class="fa fa-lg" ng-class="login.favorite ? 'fa-star' : 'fa-star-o'"></i> <i class="fa fa-lg" ng-class="login.favorite ? 'fa-star' : 'fa-star-o'"></i>
<span class="sr-only">Toggle Favorite</span> <span class="sr-only">Toggle Favorite</span>
</button> </button>