Skip to content

Commit

Permalink
fix prompt bug
Browse files Browse the repository at this point in the history
  • Loading branch information
o.istomin committed Oct 13, 2015
1 parent ea2b5d0 commit cfac8dd
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## 0.2.13

#### Bug Fixes

- **oi-select-options:**
- newItem = "prompt": fixed items saving

## 0.2.13

#### Features

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#oi.select — AngularJS directive of select element

**[Download 0.2.13](https://github.com/tamtakoe/oi.select/tree/master/dist)**
**[Download 0.2.14](https://github.com/tamtakoe/oi.select/tree/master/dist)**

## Features

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "https://github.com/tamtakoe"
},
"name": "oi.select",
"version": "0.2.13",
"version": "0.2.14",
"main": ["./dist/select-tpls.min.js", "./dist/select.min.css"],
"dependencies": {
"angular": ">=1.2",
Expand Down
20 changes: 14 additions & 6 deletions dist/select-tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ angular.module('oi.select')
saveTrigger: 'enter'
},
version: {
full: '0.2.13',
full: '0.2.14',
major: 0,
minor: 2,
dot: 13
dot: 14
},
$get: function() {
return {
Expand Down Expand Up @@ -473,15 +473,21 @@ angular.module('oi.select')
}
});

function valueChangedManually() { //case: clean model; prompt + editItem: 'correct'; initial value = defined/undefined
if (editItemIsCorrected) {
element.removeClass('cleanMode');
}
editItemIsCorrected = false;
}

scope.$parent.$watch(attrs.ngModel, function(value, oldValue) {
var output = value instanceof Array ? value : value ? [value]: [],
promise = $q.when(output);

modifyPlaceholder();

if (value !== oldValue) {
editItemIsCorrected = false;
element.removeClass('cleanMode');
if (oldValue && value !== oldValue) {
valueChangedManually();
}

if (!multiple) {
Expand Down Expand Up @@ -587,6 +593,8 @@ angular.module('oi.select')
resetMatches({query: true});
}

valueChangedManually();

scope.oldQuery = scope.oldQuery || scope.query;
scope.query = '';
scope.backspaceFocus = false;
Expand Down Expand Up @@ -913,7 +921,7 @@ angular.module('oi.select')
.finally(function(){
scope.showLoader = false;

if (options.closeList) {
if (options.closeList && !options.cleanModel) { //case: prompt
$timeout(function() {
setOption(listElement, 0);
});
Expand Down
2 changes: 1 addition & 1 deletion dist/select-tpls.min.js

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions dist/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ angular.module('oi.select')
saveTrigger: 'enter'
},
version: {
full: '0.2.13',
full: '0.2.14',
major: 0,
minor: 2,
dot: 13
dot: 14
},
$get: function() {
return {
Expand Down Expand Up @@ -473,15 +473,21 @@ angular.module('oi.select')
}
});

function valueChangedManually() { //case: clean model; prompt + editItem: 'correct'; initial value = defined/undefined
if (editItemIsCorrected) {
element.removeClass('cleanMode');
}
editItemIsCorrected = false;
}

scope.$parent.$watch(attrs.ngModel, function(value, oldValue) {
var output = value instanceof Array ? value : value ? [value]: [],
promise = $q.when(output);

modifyPlaceholder();

if (value !== oldValue) {
editItemIsCorrected = false;
element.removeClass('cleanMode');
if (oldValue && value !== oldValue) {
valueChangedManually();
}

if (!multiple) {
Expand Down Expand Up @@ -587,6 +593,8 @@ angular.module('oi.select')
resetMatches({query: true});
}

valueChangedManually();

scope.oldQuery = scope.oldQuery || scope.query;
scope.query = '';
scope.backspaceFocus = false;
Expand Down Expand Up @@ -913,7 +921,7 @@ angular.module('oi.select')
.finally(function(){
scope.showLoader = false;

if (options.closeList) {
if (options.closeList && !options.cleanModel) { //case: prompt
$timeout(function() {
setOption(listElement, 0);
});
Expand Down
2 changes: 1 addition & 1 deletion dist/select.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oi.select",
"license": "MIT",
"version": "0.2.13",
"version": "0.2.14",
"repository": {
"type": "git",
"url": "git://github.com/tamtakoe/oi.select.git"
Expand Down
16 changes: 12 additions & 4 deletions src/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,21 @@ angular.module('oi.select')
}
});

function valueChangedManually() { //case: clean model; prompt + editItem: 'correct'; initial value = defined/undefined
if (editItemIsCorrected) {
element.removeClass('cleanMode');
}
editItemIsCorrected = false;
}

scope.$parent.$watch(attrs.ngModel, function(value, oldValue) {
var output = value instanceof Array ? value : value ? [value]: [],
promise = $q.when(output);

modifyPlaceholder();

if (value !== oldValue) {
editItemIsCorrected = false;
element.removeClass('cleanMode');
if (oldValue && value !== oldValue) {
valueChangedManually();
}

if (!multiple) {
Expand Down Expand Up @@ -251,6 +257,8 @@ angular.module('oi.select')
resetMatches({query: true});
}

valueChangedManually();

scope.oldQuery = scope.oldQuery || scope.query;
scope.query = '';
scope.backspaceFocus = false;
Expand Down Expand Up @@ -577,7 +585,7 @@ angular.module('oi.select')
.finally(function(){
scope.showLoader = false;

if (options.closeList) {
if (options.closeList && !options.cleanModel) { //case: prompt
$timeout(function() {
setOption(listElement, 0);
});
Expand Down
4 changes: 2 additions & 2 deletions src/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ angular.module('oi.select')
saveTrigger: 'enter'
},
version: {
full: '0.2.13',
full: '0.2.14',
major: 0,
minor: 2,
dot: 13
dot: 14
},
$get: function() {
return {
Expand Down

0 comments on commit cfac8dd

Please sign in to comment.