Socket
Socket
Sign inDemoInstall

checklist-model

Package Overview
Dependencies
1
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 0.8.0

docs/blocks/object-static-list/ctrl.js

2

bower.json
{
"name": "checklist-model",
"version": "0.7.0",
"version": "0.8.0",
"description": "AngularJS directive for list of checkboxes",

@@ -5,0 +5,0 @@ "author": "https://github.com/vitalets",

@@ -57,2 +57,3 @@ /**

var checklistChange = $parse(attrs.checklistChange);
var checklistBeforeChange = $parse(attrs.checklistBeforeChange);

@@ -82,5 +83,19 @@ // value added to list

}
if (checklistBeforeChange && (checklistBeforeChange(scope) === false)) {
scope[attrs.ngModel] = contains(getter(scope.$parent), value, comparator);
return;
}
setValueInChecklistModel(value, newValue);
if (checklistChange) {
checklistChange(scope);
}
});
function setValueInChecklistModel(value, checked) {
var current = getter(scope.$parent);
if (angular.isFunction(setter)) {
if (newValue === true) {
if (checked === true) {
setter(scope.$parent, add(current, value, comparator));

@@ -91,11 +106,12 @@ } else {

}
}
if (checklistChange) {
checklistChange(scope);
}
});
// declare one function to be used for both $watch functions
function setChecked(newArr, oldArr) {
scope[attrs.ngModel] = contains(newArr, value, comparator);
if (checklistBeforeChange && (checklistBeforeChange(scope) === false)) {
setValueInChecklistModel(value, scope[attrs.ngModel]);
return;
}
scope[attrs.ngModel] = contains(newArr, value, comparator);
}

@@ -102,0 +118,0 @@

@@ -9,6 +9,10 @@ app.controller('Ctrl5', function($scope) {

$scope.testValue = 'Im not changed yet!';
$scope.imChanged = function(){
$scope.testValue = $scope.user.roles.join(',');
}
$scope.testValue = 'Im not changed yet!';
$scope.imChanged = function(){
$scope.testValue = $scope.user.roles.join(',');
}
$scope.shouldChange = function(key){
console.log("should change " + key);
return key !== "g";
}

@@ -15,0 +19,0 @@ $scope.user = {

@@ -13,5 +13,11 @@ describe('event', function() {

check(a, [1,0,0,0]);
expect(element(s+'pre').text()).toBe('"a"');
expect(element(s+'pre').text()).toEqual("\"a\"");
});
it('should check that checklist-before-change can deny change of values', function() {
element(s+'button[ng-click="checkAll()"]').click();
check(a, [1,1,0,1]);
expect(element(s+'pre').text()).toEqual("\"a,c,u\"");
});
});

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.7.0",
"version": "0.8.0",
"homepage": "http://vitalets.github.io/checklist-model",

@@ -8,0 +8,0 @@ "author": {

@@ -16,10 +16,11 @@ ![Bower](https://img.shields.io/bower/v/checklist-model.svg) [![NPM](https://img.shields.io/npm/v/checklist-model.svg)](https://www.npmjs.com/package/checklist-model) ![License](https://img.shields.io/npm/l/checklist-model.svg)

| Attribute | Mandatory | Description |
| :----------------: | :-------: | --------------------------------------------- |
| `checklist-model` | Yes | Use instead of `ng-model` |
| `checklist-value` | No | What should be picked as array item |
| `value` | No | What should be picked as item, but unlike `checklist-value`, this does not evaluate as an angular expression, but rather a static value |
| `ng-model` | No | Every checkbok will span a new scope and define a variable named `checked` to hold its state. You can modify this name by using this attribute. |
| `checklist-comparator` | No | A custom comparator. If it starts with dot(`.`) then it will be an expression applied to the array item. Otherwise it should evaluate to a function as an angular expression. The function return true if the first two arguments are equal and false otherwise. |
| `checklist-change` | No | An angular expression evaluated each time the `checklist-model` has changed. |
| Attribute | Mandatory | Description |
| :-----------------------: | :-------: | --------------------------------------------- |
| `checklist-model` | Yes | Use instead of `ng-model` |
| `checklist-value` | No | What should be picked as array item |
| `value` | No | What should be picked as item, but unlike `checklist-value`, this does not evaluate as an angular expression, but rather a static value |
| `ng-model` | No | Every checkbok will span a new scope and define a variable named `checked` to hold its state. You can modify this name by using this attribute. |
| `checklist-comparator` | No | A custom comparator. If it starts with dot(`.`) then it will be an expression applied to the array item. Otherwise it should evaluate to a function as an angular expression. The function return true if the first two arguments are equal and false otherwise. |
| `checklist-before-change` | No | An angular expression evaluated each time before the `checklist-model` has changed. If it evaluates to 'false' then the model will not change anymore. |
| `checklist-change` | No | An angular expression evaluated each time the `checklist-model` has changed. |

@@ -26,0 +27,0 @@ * If you modify directly the value of the `checklist-model`, it is possible that the UI won't be updated. This is because this directive looks for the model in the parent, not in the current scope. Instead of doing `checklistModelList = []` it is better to do `checklistModelList.splice(0, checklistModelList.length)` or wrap it in another object.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc