angular-json-edit
Advanced tools
Comparing version 0.0.5 to 0.1.1
{ | ||
"name": "angular-json-edit", | ||
"version": "0.0.5", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/Rleahy22/angularJsonEditor", | ||
@@ -5,0 +5,0 @@ "authors": [ |
(function() { | ||
'use strict'; | ||
angular.module('angular-json-edit', []) | ||
angular.module('angular-json-edit', []); | ||
})(); | ||
(function() { | ||
'use strict'; | ||
angular.module('angular-json-edit') | ||
.directive('jsonEditor', jsonEditor) | ||
.directive('jsonEditorAddProperty', jsonEditorAddProperty) | ||
.directive('compile', compile); | ||
@@ -34,13 +39,19 @@ | ||
function link(scope) { | ||
scope.collapse = collapse; | ||
scope.collapsed = []; | ||
scope.deleteProperty = deleteProperty; | ||
scope.expand = expand; | ||
scope.getInputType = getInputType; | ||
scope.isArray = isArray; | ||
scope.isCollapsed = isCollapsed; | ||
scope.isNested = isNested; | ||
scope.nest = '<button class="json-delete json-button" ng-click="deleteProperty(key, parent)">×</button>' + | ||
'<div class="label-wrapper">' + | ||
'<div class="label-wrapper" ng-class="{\'padded-row\': !isNested(value)}">' + | ||
'<i ng-show="isNested(value) && isCollapsed(key, parent)" class="json-arrow" ng-click="expand(key, parent)">⇒</i>' + | ||
'<i ng-show="isNested(value) && !isCollapsed(key, parent)" class="json-arrow" ng-click="collapse(key, parent)">⇓</i>' + | ||
'<label ng-hide="isArray(parent)" class="json-form-element">' + | ||
'<span class="key-span">{{key}}:</span>' + | ||
'<span ng-show="isNested(value) && isArray(value)">[</span>' + | ||
'<span ng-show="isNested(value) && !isArray(value)">{</span>' + | ||
'<span ng-show="isNested(value) && isArray(value)"> [</span>' + | ||
'<span ng-show="isNested(value) && !isArray(value)"> {</span>' + | ||
'</label>' + | ||
@@ -52,10 +63,16 @@ '<div ng-if="!isNested(value)" class="json-form-element">' + | ||
'<label ng-show="isNested(value) && !isArray(value) && isArray(parent)" class="json-form-element">{</label>' + | ||
'<div ng-if="isNested(value)" class="nested-json">' + | ||
'<div ng-if="isNested(value)" ng-show="!isCollapsed(key, parent)" class="nested-json">' + | ||
'<div ng-repeat="(key, value) in parent[key] track by key" ng-init="parent = child; child = value" class="json-form-row" compile="nest">' + | ||
'</div>' + | ||
'<div json-editor-add-property class="json-new-property padded-row" object="value" newProperty="{}" class="" ng-show="isNested(value)">' + | ||
'</div>' + | ||
'</div>' + | ||
'<div json-editor-add-property class="json-new-property" object="value" newProperty="{}" class="" ng-show="isNested(value)">' + | ||
'</div>' + | ||
'<label ng-show="isNested(value)" class="json-form-element">{{isArray(value) ? \']\' : \'}\'}}</label>'; | ||
'<label ng-show="isNested(value)" class="json-form-element padded-row">{{isArray(value) ? \']\' : \'}\'}}</label>'; | ||
function collapse(key, parent) { | ||
var newObj = {} | ||
newObj[key] = parent; | ||
scope.collapsed.push(newObj); | ||
} | ||
function deleteProperty(key, object) { | ||
@@ -69,2 +86,14 @@ if (scope.isArray(object)) { | ||
function expand(key, parent) { | ||
var check = {}; | ||
var result = false | ||
check[key] = parent; | ||
scope.collapsed.forEach(function(element, index) { | ||
if (element[key] === check[key]) { | ||
scope.collapsed.splice(index, 1); | ||
} | ||
}); | ||
} | ||
function getInputType(value) { | ||
@@ -82,2 +111,16 @@ if (typeof value === 'number') { | ||
function isCollapsed(key, parent) { | ||
var check = {}; | ||
var result = false | ||
check[key] = parent; | ||
scope.collapsed.forEach(function(element) { | ||
if (element[key] === check[key]) { | ||
result = true; | ||
} | ||
}); | ||
return result; | ||
} | ||
function isNested(value) { | ||
@@ -99,2 +142,26 @@ if (typeof value === 'object') { | ||
compile.$inject = ['$compile']; | ||
function compile($compile) { | ||
return function(scope, element, attrs) { | ||
scope.$watch( | ||
function(scope) { | ||
return scope.$eval(attrs.compile); | ||
}, | ||
function(value) { | ||
element.html(value); | ||
$compile(element.contents())(scope); | ||
} | ||
) | ||
} | ||
} | ||
})(); | ||
(function() { | ||
'use strict'; | ||
angular.module('angular-json-edit') | ||
.directive('jsonEditorAddProperty', jsonEditorAddProperty); | ||
function jsonEditorAddProperty() { | ||
@@ -113,3 +180,3 @@ var template = '<div class="new-property-div" ng-show="showForm">' + | ||
'<div class="new-property-button-div" ng-show="!showForm">' + | ||
'<button class="json-button" ng-click="showForm = true">+</button>' + | ||
'<button class="json-button padded-row" ng-click="showForm = true">+</button>' + | ||
'</div>'; | ||
@@ -170,19 +237,2 @@ | ||
} | ||
compile.$inject = ['$compile']; | ||
function compile($compile) { | ||
return function(scope, element, attrs) { | ||
scope.$watch( | ||
function(scope) { | ||
return scope.$eval(attrs.compile); | ||
}, | ||
function(value) { | ||
element.html(value); | ||
$compile(element.contents())(scope); | ||
} | ||
) | ||
} | ||
} | ||
})(); |
{ | ||
"name": "angular-json-edit", | ||
"version": "0.0.5", | ||
"version": "0.1.1", | ||
"description": "Infinitely nesting JSON editor for Angular with no dependencies", | ||
@@ -29,2 +29,3 @@ "main": "dist/angularJsonEdit.js", | ||
"gulp": "^3.9.0", | ||
"gulp-concat": "^2.6.0", | ||
"gulp-connect": "^2.2.0", | ||
@@ -34,2 +35,4 @@ "gulp-jscs": "^1.6.0", | ||
"gulp-less": "^3.0.3", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-uglify": "^1.2.0", | ||
"jasmine-core": "^2.3.4", | ||
@@ -36,0 +39,0 @@ "karma": "^0.13.3", |
# angularJsonEdit | ||
An infinitely nesting, dependency free interactive JSON editor for Angular. Can support an infinitely nested object without the need to install jQuery, bootstrap, or any ui dependencies. All changes occur within the digest cycle with no use of $scope.$watch or manually calling $scope.$digest or $scope.$apply. 100% test covered. | ||
An infinitely nesting, dependency free interactive JSON editor for Angular. Can support an infinitely nested object without the need to install jQuery, bootstrap, or any ui dependencies. All changes occur within the digest cycle with no manual calls of $scope.$digest or $scope.$apply. 100% test covered. | ||
@@ -5,0 +5,0 @@ # Usage |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
118227
31
1452
0
19