Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Juan Ferrer Toribio 2018-02-14 11:46:20 +01:00
commit cb92e48eef
13 changed files with 579 additions and 449 deletions

View File

@ -5,3 +5,4 @@ import './validation';
import './acl'; import './acl';
import './on-error-src'; import './on-error-src';
import './zoom-image'; import './zoom-image';
import './visible-by';

View File

@ -55,17 +55,17 @@ describe('Directive zoomImage', () => {
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image>`); let image = getCompiledImage(`<img src="${srcDefault}" zoom-image>`);
image[0].click(); image[0].click();
findContainer = document.getElementById(idContainer); findContainer = document.getElementById(idContainer);
let findNewImage = findContainer.querySelector('img'); let findNewImage = findContainer.querySelector('.zoomImage-background');
expect(findNewImage.src).toEqual(srcDefault); expect(findNewImage.style.backgroundImage).toEqual(`url("${srcDefault}")`);
}); });
it('should create new image, into zoom container, with src likes zoomImage value', () => { it('should create new image, into zoom container, with src likes zoomImage value', () => {
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image="${srcZoom}">`); let image = getCompiledImage(`<img src="${srcDefault}" zoom-image="${srcZoom}">`);
image[0].click(); image[0].click();
findContainer = document.getElementById(idContainer); findContainer = document.getElementById(idContainer);
let findNewImage = findContainer.querySelector('img'); let findNewImage = findContainer.querySelector('.zoomImage-background');
expect(findNewImage.src).toEqual(srcZoom); expect(findNewImage.style.backgroundImage).toEqual(`url("${srcZoom}")`);
}); });
}); });

View File

@ -0,0 +1,17 @@
import ngModule from '../module';
function vnVisibleBy(aclService) {
return {
restrict: 'A',
priority: -1,
link: function($scope, $element, $attrs) {
let acls = $attrs.vnVisibleBy.split(',');
if (!aclService.aclPermission(acls)) {
$element[0].style.visibility = 'hidden';
}
}
};
}
vnVisibleBy.$inject = ['aclService'];
ngModule.directive('vnVisibleBy', vnVisibleBy);

View File

@ -4,7 +4,6 @@ export function directive($timeout) {
let idContainer = 'zoomImage'; let idContainer = 'zoomImage';
let container; let container;
let background; let background;
let image;
function createContainers(src) { function createContainers(src) {
if (document.getElementById(idContainer)) { if (document.getElementById(idContainer)) {
@ -15,31 +14,21 @@ export function directive($timeout) {
background = document.createElement('div'); background = document.createElement('div');
background.className = 'zoomImage-background'; background.className = 'zoomImage-background';
background.style.backgroundImage = `url(${src})`;
container.appendChild(background); container.appendChild(background);
image = document.createElement('img');
image.src = src;
container.appendChild(image);
document.body.appendChild(container); document.body.appendChild(container);
$timeout(() => {
resizeImage();
container.className = 'open';
}, 250);
} }
function addListeners() { function addListeners() {
background.addEventListener('click', destroyContainers); background.addEventListener('click', destroyContainers);
document.addEventListener('keydown', e => keyDownHandler(e)); document.addEventListener('keydown', e => keyDownHandler(e));
window.addEventListener('resize', resizeImage);
} }
function removeListeners() { function removeListeners() {
if (container) { if (container) {
background.removeEventListener('click', destroyContainers); background.removeEventListener('click', destroyContainers);
document.removeEventListener('keydown', e => keyDownHandler(e)); document.removeEventListener('keydown', e => keyDownHandler(e));
window.removeEventListener('resize', resizeImage);
} }
} }
@ -57,14 +46,6 @@ export function directive($timeout) {
container = undefined; container = undefined;
background = undefined; background = undefined;
image = undefined;
}
function resizeImage() {
if (image) {
image.style.marginLeft = `-${Math.floor(image.clientWidth / 2)}px`;
image.style.marginTop = `-${Math.floor(image.clientHeight / 2)}px`;
}
} }
return { return {

View File

@ -9,32 +9,11 @@ div#zoomImage, div#zoomImage .zoomImage-background {
top: 0; top: 0;
z-index: 11; z-index: 11;
} }
div#zoomImage{
opacity: 0;
transition: visibility 0s, opacity 0.5s linear;
}
div#zoomImage .zoomImage-background{ div#zoomImage .zoomImage-background{
background: rgba(0, 0, 0, 0.7); background-color: rgba(0, 0, 0, 0.7);
cursor: zoom-out; cursor: zoom-out;
} background-repeat: no-repeat;
div#zoomImage img{ background-position: center center;
z-index: 12; background-size: auto 98%;
position: fixed;
max-height: 98%;
max-width: 98%;
left: 50%;
top: 50%;
opacity: 0;
transition: visibility 0s, opacity 1s linear;
}
div#zoomImage.open {
visibility: visible;
opacity: 1;
}
div#zoomImage.open img{
visibility: visible;
opacity: 1;
} }

View File

@ -80,17 +80,6 @@
"icon": "folder" "icon": "folder"
} }
},{ },{
"url" : "/picture",
"state": "item.card.picture",
"component": "vn-item-picture",
"params": {
"item": "$ctrl.item"
},
"menu": {
"description": "Picture",
"icon": "folder"
}
}, {
"url" : "/barcode", "url" : "/barcode",
"state": "item.card.barcode", "state": "item.card.barcode",
"component": "vn-item-barcode", "component": "vn-item-barcode",

View File

@ -3,10 +3,14 @@
<vn-auto class="descriptor-header pointer" ui-sref="item.index"> <vn-auto class="descriptor-header pointer" ui-sref="item.index">
<img ng-src="/static/images/icon_item.png"/> <img ng-src="/static/images/icon_item.png"/>
</vn-auto> </vn-auto>
<vn-auto pad-medium text-center> <vn-auto style="position: relative" pad-medium text-center>
<img <img
ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}" ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{::$ctrl.item.image}}"
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}" on-error-src/> zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{::$ctrl.item.image}}" on-error-src/>
<a href="https://www.verdnatura.es/#!form=admin/items&filter={{::$ctrl.item.id}}" target="_blank"><vn-float-button icon="edit"
style="position: absolute; bottom: 1em; right: 1em;"
vn-visible-by="administrative"></vn-float-button>
</a>
</vn-auto> </vn-auto>
<vn-auto pad-medium> <vn-auto pad-medium>
<div><span translate>Id</span>: <b>{{$ctrl.item.id}}</b></div> <div><span translate>Id</span>: <b>{{$ctrl.item.id}}</b></div>

View File

@ -11,6 +11,5 @@ import './tags/item-tags';
import './history/item-history'; import './history/item-history';
import './niche/item-niche'; import './niche/item-niche';
import './botanical/item-botanical'; import './botanical/item-botanical';
import './picture/item-picture';
import './barcode/item-barcode'; import './barcode/item-barcode';

View File

@ -8,8 +8,7 @@
on-search="$ctrl.search(index)" on-search="$ctrl.search(index)"
advanced="true" advanced="true"
popover="vn-item-filter-panel" popover="vn-item-filter-panel"
ignore-keys = "['page', 'size', 'search']" ignore-keys = "['page', 'size', 'search']">
>
</vn-searchbar> </vn-searchbar>
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>

View File

@ -13,7 +13,6 @@ Item history: Historial del artículo
Item tags: Tags del artículo Item tags: Tags del artículo
Niche: Nicho Niche: Nicho
Picture: Foto Picture: Foto
Item pictures: Fotos del artículo
Barcode: Código barras Barcode: Código barras
Item barcode: Código de barras del artículo Item barcode: Código de barras del artículo
Changed by: Cambiado por Changed by: Cambiado por

View File

@ -1,5 +0,0 @@
<vn-card>
<vn-vertical pad-large>
<vn-title>Item pictures</vn-title>
</vn-vertical>
</vn-card>

View File

@ -1,5 +0,0 @@
import ngModule from '../module';
ngModule.component('vnItemPicture', {
template: require('./item-picture.html')
});

916
package-lock.json generated

File diff suppressed because it is too large Load Diff