all files / common/core/clipboard/ clipboard.service.ts

100% Statements 14/14
100% Branches 0/0
100% Functions 6/6
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                          31×   33×     29×              
/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
 
import { Injectable } from '@angular/core';
 
/**
 * Global property bag for copy paste
 */
@Injectable()
export class DejaClipboardService {
    private clipboard = {} as { [key: string]: any };
 
    public get(key: string) {
        return this.clipboard[key];
    }
 
    public set(key: string, value: any) {
        this.clipboard[key] = value;
    }
 
    public isAvailable(key: string) {
        return !!this.clipboard[key];
    }
 
    public clear() {
        this.clipboard = {};
    }
}