Skip to content

Commit

Permalink
feat(zoom) #MAG-234 : add zoom component for board view
Browse files Browse the repository at this point in the history
  • Loading branch information
Rseuret authored and flmartineau committed Oct 3, 2023
1 parent a79828c commit f5c97f9
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,6 @@
"magneto.dropzone.overlay.solution": "Veuillez importer un <b>fichier</b>",
"magneto.dropzone.overlay.action": "J'ai compris",
"magneto.shared.push.notif.body": "a partagé avec vous un nouveau tableau",
"magneto.loading": "Chargement"
"magneto.loading": "Chargement",
"magneto.zoom": "Zoom"
}
8 changes: 8 additions & 0 deletions src/main/resources/public/sass/global/components/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,12 @@ i {
font-family: 'magneto-mdi';
content: '\F04EB';
}
&.magneto-plus::before{
font-family: 'magneto-mdi';
content: '\F0415';
}
&.magneto-minus::before{
font-family: 'magneto-mdi';
content: '\F0374';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
@import 'comments-panel';
@import 'board-description-lightbox';
@import 'favorite-button';
@import 'pdf-viewer';
@import 'pdf-viewer';
@import 'zoom';
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.zoom{
background-color: $magneto-grey;
opacity: 75%;
display: flex;
color: $magneto-white;
position: fixed;
border-radius: 32px;
padding: 8px;
right: 45%;
bottom: 1em;
z-index: 2;

&-plus{
font-size: 32px;
padding-left: 1em;
margin-top: 3px;
&-disabled{
color: $magneto-light-grey;
}
}
&-minus{
padding-right: 1em;
font-size: 32px;
margin-top: 3px;
&-disabled{
color: $magneto-light-grey;
}
}
&-label{
margin: 0 1em ;
}

&-line1 {
content: "";
position: absolute;
top: 50%;
left: 20%;
width: 40px;
height: 1px;
background-color: #ffffff;
}

&-line2 {
content: "";
position: absolute;
top: 50%;
left: 62%;
width: 40px;
height: 1px;
background-color: #ffffff;
}
}
8 changes: 7 additions & 1 deletion src/main/resources/public/template/board.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ <h1 ng-click="vm.goToBoards()" class="cell paddingRight" tooltip="[[vm.board.tit
has-comments="vm.board.canComment"
board-owner="vm.board.owner"
has-favorite="true"
display-favorite="vm.board.displayNbFavorites">
display-favorite="vm.board.displayNbFavorites"
ng-style="{'zoom': vm.zoomLevel + '%'}"
>
</card-list>
<section-list
ng-if="!!vm.board.layoutType && !vm.board.isLayoutFree()"
Expand Down Expand Up @@ -217,5 +219,9 @@ <h1 ng-click="vm.goToBoards()" class="cell paddingRight" tooltip="[[vm.board.tit
loading-mode="true"
scroll-eventer="vm.infiniteScrollService">
</infinite-scroll>
<zoom
zoom-level="vm.zoomLevel"
preferences="zoomPreferences"
></zoom>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ interface IViewModel extends ng.IController {

updateFrequency: number;

zoomLevel: number;

goToBoards(): void;

getCards(): Promise<void>;
Expand Down Expand Up @@ -171,6 +173,7 @@ class Controller implements IViewModel {

updateIntervalPromise: angular.IPromise<any>;

zoomLevel:number;
constructor(private $scope: IBoardViewScope,
private $route: any,
private $location: ng.ILocationService,
Expand All @@ -187,6 +190,7 @@ class Controller implements IViewModel {
this.navbarCollection = [];
this.COLLECTION_NAVBAR_VIEWS = COLLECTION_NAVBAR_VIEWS;
this.boardDescriptionEventer = new Subject<void>();
this.zoomLevel = 100;
}

async $onInit(): Promise<void> {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/public/ts/directives/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ export * from './comment-input/comment-input.directive';
export * from './comment-delete-lightbox/comment-delete-lightbox.directive';
export * from './board-description-lightbox/board-description-lightbox.directive';
export * from './favorite-button/favorite-button.directive';
export * from './pdf-viewer/pdf-viewer.directive'
export * from './pdf-viewer/pdf-viewer.directive';
export * from './zoom/zoom.directive';
108 changes: 108 additions & 0 deletions src/main/resources/public/ts/directives/zoom/zoom.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import {RootsConst} from "../../core/constants/roots.const";
import {ng, Me} from "entcore";


interface IViewModel extends ng.IController, ICardProfileProps {
zoomIn(): void;
zoomOut(): void;
savePreferences(): Promise<void>
resetZoom():void;

zoomReset:number;
}

interface ICardProfileProps {
zoomLevel: number;
zoomMax: number;
zoomMin: number;
zoomIncrement: number;
preferences: string;

}

interface IZoomScope extends ICardProfileProps, IViewModel {
vm: IViewModel;
}

class Controller implements IViewModel {
zoomLevel: number;
zoomMax: number;
zoomMin: number;
zoomIncrement: number
zoomReset:number
preferences: string;

constructor() {
if (this.zoomMax === undefined)
this.zoomMax = 150
if (this.zoomMin === undefined)
this.zoomMin = 50
if (this.zoomIncrement === undefined) {
this.zoomIncrement = 25
}
}

async $onInit() : Promise<void>{
await Me.preference('magneto')
if (!Me.preferences['magneto']) {
await Me.savePreference('magneto');
await Me.preference('magneto')
}
if (!Me.preferences['magneto'][this.preferences]) {
Me.preferences['magneto'][this.preferences] = this.zoomLevel;
await Me.savePreference('magneto');
await Me.preference('magneto')
}else{
this.zoomLevel = Me.preferences['magneto'][this.preferences];
}
this.zoomReset = this.zoomLevel;
}

async zoomIn(): Promise<void> {
if (this.zoomLevel < this.zoomMax)
this.zoomLevel += this.zoomIncrement;
await this.savePreferences();
}

async savePreferences():Promise<void> {
Me.preferences['magneto'][this.preferences] = this.zoomLevel;
await Me.savePreference('magneto');
}

async zoomOut(): Promise<void> {
if (this.zoomLevel > this.zoomMin)
this.zoomLevel -= this.zoomIncrement;
Me.preferences['magneto'][this.preferences] = this.zoomLevel;
await Me.savePreference('magneto');
}

resetZoom():void {
this.zoomLevel = this.zoomReset;
}

}

function directive() {
return {
restrict: 'E',
templateUrl: `${RootsConst.directive}zoom/zoom.html`,
scope: {
zoomLevel: '=',
zoomMax: '=?',
zoomMin: '=?',
zoomIncrement: '=?',
preferences: '@'
},
controllerAs: 'vm',
bindToController: true,
controller: ['$scope', '$location', '$window', Controller],
/* interaction DOM/element */
link: function ($scope: IZoomScope,
element: ng.IAugmentedJQuery,
attrs: ng.IAttributes,
vm: IViewModel) {
}
}
}

export const zoom = ng.directive('zoom', directive)
17 changes: 17 additions & 0 deletions src/main/resources/public/ts/directives/zoom/zoom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="zoom">

<div class="zoom-minus" ng-click="vm.zoomOut()" ng-disabled="vm.zoomLevel === vm.zoomMin"
ng-class="{'zoom-minus-disabled' : vm.zoomLevel === vm.zoomMin}">
<i class="magneto-minus" ></i>
</div>
<div class="zoom-line1"></div>
<div class="zoom-label" ng-click="vm.resetZoom()">
<i18n>magneto.zoom</i18n>
</div>
<div class="zoom-line2"></div>
<div class="zoom-plus" ng-click="vm.zoomIn()" ng-disabled="vm.zoomLevel === vm.zoomMax"
ng-class="{'zoom-plus-disabled' : vm.zoomLevel === vm.zoomMax}">
<i class="magneto-plus"></i>
</div>

</div>

0 comments on commit f5c97f9

Please sign in to comment.