corrected some eslint errors and small refactor

This commit is contained in:
Carlos 2017-11-13 22:15:44 +01:00
parent ed64c3b50a
commit 29149b1b58
12 changed files with 57 additions and 40 deletions

View File

@ -1,18 +1,18 @@
<div> <div>
<div class="box-wrapper"> <div class="box-wrapper">
<div class="box"> <div class="box">
<img src="./logo.svg"/> <img src="./logo.svg"/>
<form name="form" ng-submit="$ctrl.submit()"> <form name="form" ng-submit="$ctrl.submit()">
<vn-textfield vn-id="userField" label="User" model="$ctrl.user" vn-focus></vn-textfield> <vn-textfield vn-id="userField" label="User" model="$ctrl.user" vn-focus></vn-textfield>
<vn-textfield label="Password" model="$ctrl.password" type="password"></vn-textfield> <vn-textfield label="Password" model="$ctrl.password" type="password"></vn-textfield>
<div class="footer"> <div class="footer">
<vn-submit label="Enter"></vn-submit> <vn-submit label="Enter"></vn-submit>
<div class="spinner-wrapper"> <div class="spinner-wrapper">
<vn-spinner enable="$ctrl.loading"></vn-spinner> <vn-spinner enable="$ctrl.loading"></vn-spinner>
</div>
</div> </div>
</div> </form>
</form> </div>
</div>
</div> </div>
<vn-snackbar vn-id="snackbar"></vn-snackbar> <vn-snackbar vn-id="snackbar"></vn-snackbar>
</div> </div>

View File

@ -16,6 +16,7 @@ vn-login > div {
margin: auto; margin: auto;
height: inherit; height: inherit;
} }
.box { .box {
box-sizing: border-box; box-sizing: border-box;
position: absolute; position: absolute;
@ -27,15 +28,18 @@ vn-login > div {
box-shadow: 0 0 1em 0 rgba(1,1,1,.6); box-shadow: 0 0 1em 0 rgba(1,1,1,.6);
border-radius: .5em; border-radius: .5em;
} }
img { img {
width: 100%; width: 100%;
padding-bottom: 1em; padding-bottom: 1em;
} }
.footer { .footer {
margin-top: 1em; margin-top: 1em;
text-align: center; text-align: center;
position: relative; position: relative;
} }
.spinner-wrapper { .spinner-wrapper {
position: absolute; position: absolute;
width: 0; width: 0;

View File

@ -1,3 +1,3 @@
vn-descriptor{ vn-descriptor {
font-family: raleway-bold; font-family: raleway-bold;
} }

View File

@ -11,6 +11,6 @@ vn-item-client a:hover {
background-color: #424242; background-color: #424242;
} }
.vn-item-client-name{ .vn-item-client-name {
font-family: raleway-bold; font-family: raleway-bold;
} }

View File

@ -6,11 +6,13 @@ export default class Controller {
this.$http = $http; this.$http = $http;
this.$state = $state; this.$state = $state;
} }
$onChanges() { $onChanges() {
if (this.client) { if (this.client) {
this.getObservation(this.client.id); this.getObservation(this.client.id);
} }
} }
getObservation(clientId) { getObservation(clientId) {
let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'}); let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'});
this.$http.get(`/client/api/clientObservations?filter=${json}`).then( this.$http.get(`/client/api/clientObservations?filter=${json}`).then(
@ -19,6 +21,7 @@ export default class Controller {
} }
); );
} }
newObservation() { newObservation() {
this.$state.go("clientCard.notes.create", {id: this.client.id}); this.$state.go("clientCard.notes.create", {id: this.client.id});
} }

View File

@ -1,3 +1,3 @@
.notes-date{ .notes-date {
font-family: raleway-bold; font-family: raleway-bold;
} }

View File

@ -6,15 +6,18 @@ export default class Controller {
// onSubmit() is defined by @vnSearchbar // onSubmit() is defined by @vnSearchbar
this.onSubmit = () => {}; this.onSubmit = () => {};
} }
onSearch() { onSearch() {
this.setStorageValue(); this.setStorageValue();
this.onSubmit(this.filter); this.onSubmit(this.filter);
} }
$onChanges() { $onChanges() {
var value = JSON.parse(this.$window.sessionStorage.getItem('filter')); var value = JSON.parse(this.$window.sessionStorage.getItem('filter'));
if (value !== undefined) if (value !== undefined)
this.filter = value; this.filter = value;
} }
setStorageValue() { setStorageValue() {
this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter)); this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter));
} }

View File

@ -17,7 +17,7 @@ describe('Client', () => {
})); }));
describe('onSearch()', () => { describe('onSearch()', () => {
it(`should call setStorageValue() and onSubmit()`, () => { it('should call setStorageValue() and onSubmit()', () => {
spyOn(controller, 'setStorageValue'); spyOn(controller, 'setStorageValue');
spyOn(controller, 'onSubmit'); spyOn(controller, 'onSubmit');
controller.setStorageValue(); controller.setStorageValue();
@ -29,7 +29,7 @@ describe('Client', () => {
}); });
describe('$onChanges()', () => { describe('$onChanges()', () => {
it(`should set filter properties using the search values`, () => { it('should set filter properties using the search values', () => {
expect(controller.filter).not.toBeDefined(); expect(controller.filter).not.toBeDefined();
spyOn(JSON, 'parse').and.returnValue({data: 'data'}); spyOn(JSON, 'parse').and.returnValue({data: 'data'});
controller.$onChanges(); controller.$onChanges();

View File

@ -29,6 +29,7 @@ export default class Controller {
this.repeatPassword = ''; this.repeatPassword = '';
this.$.$apply(); this.$.$apply();
} }
onPassChange(response) { onPassChange(response) {
if (response == 'ACCEPT' && this.canChangePassword) if (response == 'ACCEPT' && this.canChangePassword)
try { try {

View File

@ -32,6 +32,7 @@ class Autocomplete extends Component {
get showDropDown() { get showDropDown() {
return this._showDropDown; return this._showDropDown;
} }
set showDropDown(value) { set showDropDown(value) {
if (value && this.url && !this._preLoad) { if (value && this.url && !this._preLoad) {
this._preLoad = true; this._preLoad = true;
@ -77,6 +78,7 @@ class Autocomplete extends Component {
get field() { get field() {
return this.multiple ? this._multiField : this._field; return this.multiple ? this._multiField : this._field;
} }
set field(value) { set field(value) {
if (!angular.equals(value, this.field)) { if (!angular.equals(value, this.field)) {
this.finding = true; this.finding = true;
@ -103,7 +105,7 @@ class Autocomplete extends Component {
if (value && value.hasOwnProperty(this.valueField)) { if (value && value.hasOwnProperty(this.valueField)) {
this._field = value[this.valueField]; this._field = value[this.valueField];
if (this.multiple) { if (this.multiple) {
this._multiField = [value[this.valueField]] this._multiField = [value[this.valueField]];
} }
if (value.hasOwnProperty(this.showField)) { if (value.hasOwnProperty(this.showField)) {
this.displayValue = value[this.showField]; this.displayValue = value[this.showField];
@ -164,6 +166,7 @@ class Autocomplete extends Component {
json => this.onItemRequest(null) json => this.onItemRequest(null)
); );
} }
onItemRequest(data) { onItemRequest(data) {
if (data && data.length > 0) if (data && data.length > 0)
this.showItem(data[0]); this.showItem(data[0]);
@ -222,6 +225,7 @@ class Autocomplete extends Component {
this.getItems(); this.getItems();
} }
} }
getItems() { getItems() {
if (this.url === undefined) { if (this.url === undefined) {
this.items = copyObject(this.data); this.items = copyObject(this.data);
@ -273,6 +277,7 @@ class Autocomplete extends Component {
} }
} }
} }
$onInit() { $onInit() {
this.findMore = this.url && this.maxRow; this.findMore = this.url && this.maxRow;
this.mouseFocus = false; this.mouseFocus = false;
@ -321,7 +326,6 @@ class Autocomplete extends Component {
} }
} }
Autocomplete.$inject = ['$element', '$scope', '$http', '$timeout', '$filter']; Autocomplete.$inject = ['$element', '$scope', '$http', '$timeout', '$filter'];
module.component('vnAutocomplete', { module.component('vnAutocomplete', {

View File

@ -1,6 +1,8 @@
{ {
"initial:before": { "initial:before": {
"loopback#favicon": {} "loopback#favicon": {
"params": "$!../favicon.ico"
}
}, },
"initial": { "initial": {
"compression": {}, "compression": {},

View File

@ -1,24 +1,24 @@
<!doctype html> <!doctype html>
<html ng-app="salix"> <html ng-app="salix">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Salix</title> <title>Salix</title>
<script src="/acl"></script> <script src="/acl"></script>
</head> </head>
<body> <body>
<vn-app></vn-app> <vn-app></vn-app>
<script type="text/javascript" <script type="text/javascript"
src="/static/routes.js"> src="/static/routes.js">
</script> </script>
<script type="text/javascript" <script type="text/javascript"
src="/static/bundle.manifest.js"> src="/static/bundle.manifest.js">
</script> </script>
<script type="text/javascript" <script type="text/javascript"
src="/static/bundle.vendor.js"> src="/static/bundle.vendor.js">
</script> </script>
<script type="text/javascript" <script type="text/javascript"
src="/static/bundle.salix.js"> src="/static/bundle.salix.js">
</script> </script>
</body> </body>
</html> </html>