-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
-Fix some flickers issues in sortable (again!) -Remove the possibility to select text in the draggable / droppable container.
Fix insert parameter in droppable directive bind
Rework droppable binding. Rework sortable binding. Fix undefined accepted actions on sortable
First work on sortable insertion behavior
Je submit la PR.. mais je dois encore terminer 1 truc ou 2 lundi. Je submit tout suite qu'on puisse la regarder pour éventuellement release mercredi |
add event.stopPropagation where events are handled by custom code. Add m--is-grabbing class for desktop
Support is limited.. will fully work on edge but will only partially work fir all other browsers
…rify if the element has a vue instance. If it does, emit the event through the $emit service. Else, use native element.dispatchEvent
fix droppable leave on firefox.
… everything is detached when the binding of each direction = false
…he element after a drop if the drop wasn't accepted.
src/directives/domPlugin.ts
Outdated
element[constructorFunction.defaultMountPoint] = plugin; | ||
return plugin; | ||
} else { | ||
return new NullObjectMElementPlugin(options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si le plugin est finalement pas mount pour une raison quelconque, je retourne un null object pour avoir à fairep lein de if (pluginExist) partout dans le code. C'tait trop tannant
if (this.options.canDrag === undefined) { this.options.canDrag = true; } | ||
if (this.options.canDrag) { | ||
mount(() => { | ||
this.element.classList.add(MDraggableClassNames.Draggable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
le mount permet au attach de décider, selon une condition, si on veut ou pas associer la logique de directive à l'élément.
src/directives/domPlugin.ts
Outdated
Mounted = 'mounted', | ||
UnMounted = 'unmounted' | ||
} | ||
export abstract class MElementPlugin<OptionsType> implements IMElementPlugin<OptionsType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai jamais expliqué pk j'ai eu à faire ça mais voilà =>
Avec le drag and drop je dois être capable de gérer les 2 situations suivantes =>
1- pouvoir drag / drop / sort en associant une directive à l'élément
2- je dois aussi être en mesure de "composer" dynamiquement le comportement d'une directive. Pour éviter la duplication de code, fallait donc que j'extract la logique des directives sortable / droppable afin de pouvoir les composer dans sortable :)
getInsertPosition(event: MDropEvent): MSortInsertPositions; | ||
} | ||
|
||
export class MSortableDefaultInsertionMarkerBehavior implements MSortableInsertionMarkerBehavior { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Permet de définir le comportement de sort before / after. On pourrait ensuite imaginer qu'un component implémente un interface semblable et laisser le component dicter le comportement du "insert" (before, on, after)
this.showPlaceHolder(); | ||
element.insertAdjacentElement(insertPosition, this.placeHolderElement); | ||
private getInsertionMarkerBehavior(): MSortableInsertionMarkerBehavior { | ||
/*const droppable: MDroppable = MDroppable.currentHoverDroppable as MDroppable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sera commenté out dasns une prochaine itération
import { DirectiveOptions, VNodeDirective, VNode, PluginObject } from 'vue'; | ||
import { REMOVE_USER_SELECT } from '../directive-names'; | ||
|
||
export class MRemoveUserSelect extends MElementPlugin<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directive qui enlève la possibilité au user de
Sélectionner du texte en "draggant" dessus sur desktop.
En double clickant sur desktop.
En faisant un long touch sur mobile
__vue__: any; | ||
} | ||
export const dispatchEvent = (element: HTMLElement, eventName: string, eventData: any): void => { | ||
const vueElement: VueElement = element as VueElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ceci est un peu un hack. Mes directives Droppable / Sortables / Draggable doivent pouvoir émettre des events dans le bus de Vue JS si possible. En gros, si on mount la directive sur un component, il est impératif qu'on $emit via l'instance vue.. sinon l'évènement se perd dans le néant.
@@ -0,0 +1,89 @@ | |||
import { DRAGGABLE_ALLOW_SCROLL } from '../directive-names'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Permet le scroll natif des browsers sur desktop quand on dragOver sur un élément position: fixed. C'est un peu hacky mais ça règle notre problème pour pas cher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encore une fois j'ai noté quelques petites choses mineures au niveau syntaze principalement. Honnêtement il y a beaucoup de trop de code pour que je puisse regarder le "mécanique" de tout ça. Éventuellement faudrait prévoir un peu de temps pour que tu présentes tout ça à quelques développeurs, ne serait-ce que pour en faire la maintenance.
Tu rajouteras l'info nécessaire dans la description du PR #194 et on merge!
src/directives/directive-names.ts
Outdated
@@ -1,7 +1,9 @@ | |||
export const DRAGGABLE: string = 'm-draggable'; | |||
export const DRAGGABLE_ALLOW_SCROLL: string = 'm-draggable-allow-scroll'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mets un suffixe _NAME à tes noms de directives. ça m'avait échappé le premier coup puisque je voyais juste les nouvelles directives dans le file-change-viewer de github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. J'ai fix TEXTAREA_AUTO_HEIGHT au passage
src/directives/domPlugin.ts
Outdated
} | ||
} | ||
|
||
export interface IMElementPlugin<OptionsType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas besoin de préfixer le nom de l'interface avec un "I". Les internets ont déjà explosé à ce sujet :) microsoft/TypeScript-Handbook#121
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas de troubles avec ça!
src/directives/domPlugin.ts
Outdated
protected attachedEvents: Map<string, EventListenerOrEventListenerObject[]> = new Map<string, EventListenerOrEventListenerObject[]>(); | ||
protected _options: OptionsType; | ||
private readonly _element: HTMLElement; | ||
public get element(): HTMLElement { return this._element; } | ||
private _status: MElementPluginStatus = MElementPluginStatus.UnMounted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Côté convention, je ne m'y étais pas vraiment attardé, mais je ne crois pas utile de préfixer par un ' _ ' les attributs private. Typiquement, si tu déclares l'attribut privé, le "compilateur" ne te laissera pas y accéder à l'extérieur de la classe. J'ai vu par contre la convention du ' _ ' dans du pur Javascript, puisque tout est accessible de partout. Typescript lui-même va générer des attributs préfixés de ' _ ' lorsqu'il produit le Javascript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai enlevé le status.
Dans les faits j'utilise _someThing quand on cache une propriété derrière un get / set
private myProperty;
public get myProperty() { return this..myProperty }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bon point pour le cas du get/set
bind(element: HTMLElement, binding: VNodeDirective, node: VNode): void { | ||
MDOMPlugin.attach(MDraggable, element, extractVnodeAttributes(node)); | ||
inserted(element: HTMLElement, binding: VNodeDirective, node: VNode): void { | ||
const test = MDOMPlugin.attach(MDraggable, element, extractVnodeAttributes(binding, node)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
à quoi sert le "test" ici?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
À rien. Oublie
import { MDroppable } from '../droppable/droppable'; | ||
import { MElementPlugin, MDOMPlugin, MountFunction, RefreshFunction } from '../domPlugin'; | ||
import { getVNodeAttributeValue, dispatchEvent } from '../../utils/vue/directive'; | ||
import { MDroppable, MDroppableClassNames } from '../droppable/droppable'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MDroppableClassNames ne semble pas utilisé dans la classe
import { MDroppable, MDroppableClassNames } from '../droppable/droppable'; | ||
import { clearUserSelection } from '../../utils/selection/selection'; | ||
import { MRemoveUserSelect } from '../user-select/remove-user-select'; | ||
import { MSortable } from '../sortable/sortable'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSortable ne semble pas utilisé dans la classe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mboulianne Installe l'extension typescript hero pour auto nettoyer tes imports au save
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je l'avais déjà install.. je l'avais juste pas config comme du monde :(
@ulaval/modul-components
PR Checklist
Provide a small description of the changes introduced by this PR
V2 du drag and drop.
Include links to issues
MODUL-21
Include this section in the release notes
Drag and drop v2
Ajout d'une classe m--is-grabbing quand on "grab" un élément draggable.
Gestion de l'update dynamiques des propriétés des directives. (:x-y-z="abc")
Permettre le scroll sur les entête position: fixed. v-m-draggable-allow-scroll. Fix s'applique seulement si le polyfill est actif.
Ne pas permettre la sélection (long touch, double click, etc) sur les éléments draggable ou droppable.
Gestion du ghost image (sauf sur edge)
Ajout de quelques tests pour les bouts les plus simples. (à suivre)
Assurer que les transition-group fonctionnent
Beaucoup de fix pour bug de compatibilité cross-browser
Other info
Début d'une doc pour confluence pour aider les devs à débuter l'intégration.
Doc Sortable/Droppable/Sortable