Image selection deletion works now
This commit is contained in:
parent
03f992811d
commit
0f018f87dd
@ -12,7 +12,9 @@ import { error } from '../services/console.js';
|
|||||||
import { ImageType } from '../data/image.js';
|
import { ImageType } from '../data/image.js';
|
||||||
import { pouchDocArrayHash, pouchDocHash, hashSet, extractID } from '../utils/conversion.js';
|
import { pouchDocArrayHash, pouchDocHash, hashSet, extractID } from '../utils/conversion.js';
|
||||||
import { AlbumTemplate } from './components/albumTemplate.js';
|
import { AlbumTemplate } from './components/albumTemplate.js';
|
||||||
|
import { Icon } from './components/icon.js';
|
||||||
import { injectStyle, styled } from '../services/style.js';
|
import { injectStyle, styled } from '../services/style.js';
|
||||||
|
import { CLICKABLE } from './styles.js';
|
||||||
|
|
||||||
export function uploadImages(evt, files) {
|
export function uploadImages(evt, files) {
|
||||||
Array.from(files || evt.currentTarget.files).forEach(ImageType.upload);
|
Array.from(files || evt.currentTarget.files).forEach(ImageType.upload);
|
||||||
@ -51,6 +53,22 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
function renderAppBarButtons() {
|
function renderAppBarButtons() {
|
||||||
|
if (selectMode()) {
|
||||||
|
return [
|
||||||
|
trashButtonContainer(
|
||||||
|
{
|
||||||
|
onclick: deleteSelectedImages
|
||||||
|
},
|
||||||
|
[
|
||||||
|
Icon({
|
||||||
|
name: 'trash',
|
||||||
|
size: 0.75
|
||||||
|
})
|
||||||
|
]
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
el('button', [el('label', { for: 'uploadButton' }, 'Upload')]),
|
el('button', [el('label', { for: 'uploadButton' }, 'Upload')]),
|
||||||
el('input', {
|
el('input', {
|
||||||
@ -64,11 +82,12 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// function deleteImage(i) {
|
function deleteSelectedImages() {
|
||||||
// ImageType.delete(i._id);
|
selectedIds.forEach(ImageType.delete);
|
||||||
// }
|
selectedIds.clear();
|
||||||
//
|
}
|
||||||
|
|
||||||
// function addAlbum() {
|
// function addAlbum() {
|
||||||
// const albumName = prompt("Album Name");
|
// const albumName = prompt("Album Name");
|
||||||
// if (albumName && albumName.trim()) {
|
// if (albumName && albumName.trim()) {
|
||||||
@ -162,7 +181,7 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
|||||||
|
|
||||||
return function() {
|
return function() {
|
||||||
return el(
|
return el(
|
||||||
'.eventSnarfer',
|
'div',
|
||||||
{
|
{
|
||||||
onclick: {
|
onclick: {
|
||||||
'.photoSelect .icon svg path': toggleSelect,
|
'.photoSelect .icon svg path': toggleSelect,
|
||||||
@ -176,3 +195,10 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const trashButtonContainer = styled(
|
||||||
|
{
|
||||||
|
marginRight: '1em'
|
||||||
|
},
|
||||||
|
CLICKABLE
|
||||||
|
);
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
import { prop } from 'frptools';
|
import { prop } from 'frptools';
|
||||||
|
|
||||||
import { subscribeToRender, defineView as vw, defineElement as el } from '../utils/domvm.js';
|
import {
|
||||||
|
subscribeToRender,
|
||||||
|
defineView as vw,
|
||||||
|
createView as cv,
|
||||||
|
defineElement as el,
|
||||||
|
injectView as iv
|
||||||
|
} from '../utils/domvm.js';
|
||||||
import { ImageType } from '../data/image.js';
|
import { ImageType } from '../data/image.js';
|
||||||
import { AlbumType } from '../data/album.js';
|
import { AlbumType } from '../data/album.js';
|
||||||
import { ThumbnailTemplate } from './components/thumbnail.js';
|
import { ThumbnailTemplate } from './components/thumbnail.js';
|
||||||
@ -17,8 +23,7 @@ export function GalleryView(vm) {
|
|||||||
let laCleanup = null;
|
let laCleanup = null;
|
||||||
const context = {};
|
const context = {};
|
||||||
const hasData = prop(null);
|
const hasData = prop(null);
|
||||||
|
const appbar = cv(AppBarView, {}, 'appbar', context);
|
||||||
subscribeToRender(vm, [hasData]);
|
|
||||||
|
|
||||||
routeChanged.subscribe(function onRouteChange(name, params) {
|
routeChanged.subscribe(function onRouteChange(name, params) {
|
||||||
if (name == 'photos') {
|
if (name == 'photos') {
|
||||||
@ -54,7 +59,7 @@ export function GalleryView(vm) {
|
|||||||
|
|
||||||
function renderMain() {
|
function renderMain() {
|
||||||
return [
|
return [
|
||||||
vw(AppBarView, {}, 'appbar', context),
|
iv(appbar),
|
||||||
content(
|
content(
|
||||||
{
|
{
|
||||||
onscroll: handleContentScroll
|
onscroll: handleContentScroll
|
||||||
@ -64,6 +69,8 @@ export function GalleryView(vm) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subscribeToRender(vm, [hasData]);
|
||||||
|
|
||||||
return function render() {
|
return function render() {
|
||||||
if (hasData() === null) {
|
if (hasData() === null) {
|
||||||
return Overlay([el('h1', 'Loading...')]);
|
return Overlay([el('h1', 'Loading...')]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user