<commit_before>import * as keyCodes from '../keyboard/keyCodes.service';

const MODULE_NAME = 'solitude.restrict.tabbing.service';

/**
* The RestrictTabbingService class restricts keyboard tabbing, when enabled,
* to the rootNode passed into the RestrictTabbingService class.
*
* @class
* @type Class
* @return public API
*/
export class RestrictTabbingService {
    constructor(rootNode) {
        this.rootNode = rootNode;
        this.cacheNodes();
        this.prepareDOM();
        this.keyDownListener = _.bind(this.keyDownListener, this);
    }

    checkNodes() {
        let nodes = true;

        if (!this.rootNode || this.selectors.length === 0) {
            console.info('RestrictTabbingService. Missing DOM nodes. The tabbing service is inoperable.');
            nodes = false;
        }

        return nodes;
    }

    cacheNodes() {
        if (!this.rootNode) {
            console.info('RestrictTabbingService. Missing DOM nodes. The tabbing service is inoperable.');
            return;
        }

        this.selectors = this.rootNode.querySelectorAll(':scope a, :scope button');
        this.selectors = _.map(this.selectors, (node) => {
            node.setAttribute('data-tabbing-id', _.uniqueId());
            return node;
        });
    }

    prepareDOM() {
        if (!this.checkNodes()) {
            return;
        }

        this.selectors[0].focus();
    }

    enable() {
        if (!this.checkNodes()) {
            return;
        }

        this.rootNode.addEventListener('keydown', this.keyDownListener, false);
    }

    disable() {
        if (!this.checkNodes()) {
            return;
        }

        this.rootNode.removeEventListener('keydown', this.keyDownListener, false);
    }

    calculateKeyDownFocus(e) {
        if (!this.checkNodes()) {
            return;
        }

        if (!e) {
            console.info('RestrictTabbingService. Missing event.');
            return;
        }

        let firstSelector = this.selectors[0],
            firstSelectorId = firstSelector.getAttribute('data-tabbing-id'),
            activeElement = document.activeElement,
            activeElementId = activeElement.getAttribute('data-tabbing-id'),
            shiftKey = e.shiftKey,
            position = 0;

        for (let i = 0; i < this.selectors.length; i++) {
            let selectorId = this.selectors[i].getAttribute('data-tabbing-id');

            if (activeElementId === selectorId) {
                if (!shiftKey) {
                    position = (i + 1);
                    if (position >= this.selectors.length) {
                        position = 0;
                    }
                } else {
                    position = (i - 1);
                    if (position < 0) {
                        position = (this.selectors.length - 1);
                    }
                }

                this.selectors[position].focus();
            }
        }
    }

    keyDownListener(e) {
        if (!this.checkNodes()) {
            return;
        }

        if (!e) {
            console.info('RestrictTabbingService. Missing event.');
            return;
        }

        if (e.keyCode === keyCodes.TAB) {
            e.preventDefault();
            e.stopImmediatePropagation();
            this.calculateKeyDownFocus(e)
        }
    }
}
<commit_msg>Resolve IE11 navigation opening defect.<commit_after>import * as keyCodes from '../keyboard/keyCodes.service';

const MODULE_NAME = 'solitude.restrict.tabbing.service';

/**
* The RestrictTabbingService class restricts keyboard tabbing, when enabled,
* to the rootNode passed into the RestrictTabbingService class.
*
* @class
* @type Class
* @return public API
*/
export class RestrictTabbingService {
    constructor(rootNode) {
        this.rootNode = rootNode;
        this.cacheNodes();
        this.prepareDOM();
        this.keyDownListener = _.bind(this.keyDownListener, this);
    }

    checkNodes() {
        let nodes = true;

        if (!this.rootNode || this.selectors.length === 0) {
            console.info('RestrictTabbingService. Missing DOM nodes. The tabbing service is inoperable.');
            nodes = false;
        }

        return nodes;
    }

    cacheNodes() {
        if (!this.rootNode) {
            console.info('RestrictTabbingService. Missing DOM nodes. The tabbing service is inoperable.');
            return;
        }

        // The :scope syntax, used in conjunction with querySelectorAll is not yet supported by IE11.
        this.selectors = this.rootNode.querySelectorAll('a, button');
        this.selectors = _.map(this.selectors, (node) => {
            node.setAttribute('data-tabbing-id', _.uniqueId());
            return node;
        });
    }

    prepareDOM() {
        if (!this.checkNodes()) {
            return;
        }

        this.selectors[0].focus();
    }

    enable() {
        if (!this.checkNodes()) {
            return;
        }

        this.rootNode.addEventListener('keydown', this.keyDownListener, false);
    }

    disable() {
        if (!this.checkNodes()) {
            return;
        }

        this.rootNode.removeEventListener('keydown', this.keyDownListener, false);
    }

    calculateKeyDownFocus(e) {
        if (!this.checkNodes()) {
            return;
        }

        if (!e) {
            console.info('RestrictTabbingService. Missing event.');
            return;
        }

        let firstSelector = this.selectors[0],
            firstSelectorId = firstSelector.getAttribute('data-tabbing-id'),
            activeElement = document.activeElement,
            activeElementId = activeElement.getAttribute('data-tabbing-id'),
            shiftKey = e.shiftKey,
            position = 0;

        for (let i = 0; i < this.selectors.length; i++) {
            let selectorId = this.selectors[i].getAttribute('data-tabbing-id');

            if (activeElementId === selectorId) {
                if (!shiftKey) {
                    position = (i + 1);
                    if (position >= this.selectors.length) {
                        position = 0;
                    }
                } else {
                    position = (i - 1);
                    if (position < 0) {
                        position = (this.selectors.length - 1);
                    }
                }

                this.selectors[position].focus();
            }
        }
    }

    keyDownListener(e) {
        if (!this.checkNodes()) {
            return;
        }

        if (!e) {
            console.info('RestrictTabbingService. Missing event.');
            return;
        }

        if (e.keyCode === keyCodes.TAB) {
            e.preventDefault();
            e.stopImmediatePropagation();
            this.calculateKeyDownFocus(e)
        }
    }
}
<|endoftext|>


<commit_before>(function () {
    'use strict';

    angular
        .module('promort.slides_manager.controllers')
        .controller('QualityControlController', QualityControlController);

    QualityControlController.$inject = ['$scope', '$routeParams', '$location',
        'SlideService', 'QualityControlService', 'ReviewStepsService'];

    function QualityControlController($scope, $routeParams, $location, SlideService,
                                      QualityControlService, ReviewStepsService) {
        var vm = this;
        vm.slide_id = undefined;
        vm.case_id = undefined;
        vm.stainings = undefined;
        vm.not_adequacy_reasons = undefined;
        vm.checkStainingFormSubmission = checkStainingFormSubmission;
        vm.checkQCFormSubmission = checkQCFormSubmission;
        vm.submitStaining = submitStaining;
        vm.submitQualityControl = submitQualityControl;

        vm.slideStainingSubmitted = false;
        vm.slideStaining = undefined;
        vm.slideQualityControl = {};
        vm.reviewNotes = '';

        activate();

        function activate() {
            vm.slide_id = $routeParams.slide;
            vm.case_id = $routeParams.case;
            SlideService.get(vm.slide_id)
                .then(getSlideSuccessFn, getSlideErrorFn);

            function getSlideSuccessFn(response) {
                if (response.data.quality_control === null) {
                    // initialize not_adequacy_reason
                    QualityControlService.fetchNotAdequacyReasons()
                        .then(fetchNotAdequacyReasonSuccessFn);
                    //noinspection JSAnnotator
                    function fetchNotAdequacyReasonSuccessFn(response) {
                        vm.not_adequacy_reasons = response.data;
                    }
                    //initialize staining
                    SlideService.fetchStainings()
                        .then(fetchStainingSuccessFn);
                    //noinspection JSAnnotator
                    function fetchStainingSuccessFn(response) {
                        vm.stainings = response.data;
                    }
                    if (response.data.staining !== null) {
                        vm.slideStaining = response.data.staining;
                        vm.slideStainingSubmitted = true;
                    }
                } else {
                    $location.url('worklist/' + vm.case_id + '/' + vm.slide_id + '/rois_manager');
                }
            }

            function getSlideErrorFn(response) {
                console.error('Cannot load slide info');
                console.error(response);
            }
/*            QualityControlService.get(vm.slide_id)
                .then(qualityControlSuccessFn, qualityControlErrorFn);

            function qualityControlSuccessFn(response) {
                // move to the ROIs review page
                $location.url('worklist/' + vm.case_id + '/' + vm.slide_id + '/rois_manager');
            }

            function qualityControlErrorFn(response) {
                if (response.status === 404) {
                    // initialize not_adequacy_reason
                    QualityControlService.fetchNotAdequacyReasons()
                        .then(fetchNotAdequacyReasonSuccessFn);
                    //noinspection JSAnnotator
                    function fetchNotAdequacyReasonSuccessFn(response) {
                        vm.not_adequacy_reasons = response.data;
                    }
                    //initialize staining
                    SlideStainingService.fetchStainings()
                        .then(fetchStainingSuccessFn);
                    //noinspection JSAnnotator
                    function fetchStainingSuccessFn(response) {
                        vm.stainings = response.data;
                    }
                } else {
                    console.error(response.error);
                }
            }*/
        }

        function checkStainingFormSubmission() {
            return !(typeof vm.slideStaining === 'undefined');
        }

        function checkQCFormSubmission() {
            if (!vm.slideStainingSubmitted) {
                return false;
            }
            if (vm.slideQualityControl.goodImageQuality &&
                vm.slideQualityControl.goodImageQuality === 'true') {
                return true;
            }
            if (vm.slideQualityControl.goodImageQuality &&
                vm.slideQualityControl.goodImageQuality === 'false' &&
                vm.slideQualityControl.notAdequacyReason) {
                return true;
            }
            return false;
        }

        function submitStaining() {
            SlideService.updateSliceStaining(
                vm.slide_id,
                vm.slideStaining
            ).then(slideStainingUpdateSuccessFn, slideStainingUpdateErrorFn);

            function slideStainingUpdateSuccessFn(response) {
                vm.slideStainingSubmitted = true;
            }

            function slideStainingUpdateErrorFn(response) {
                console.error('Unable to update slide staining');
                console.error(response);
            }
        }

        function submitQualityControl() {
            QualityControlService.create(
                vm.slide_id,
                $.parseJSON(vm.slideQualityControl.goodImageQuality),
                vm.slideQualityControl.notAdequacyReason
            ).then(qualityControlCreationSuccessFn, qualityControlCreationErrorFn);

            function qualityControlCreationSuccessFn(response) {
                if(vm.slideQualityControl.goodImageQuality === 'true') {
                    $location.url('worklist/' + vm.case_id + '/' + vm.slide_id + '/rois_manager');
                } else {
                    // close the review because image quality is bad
                    ReviewStepsService.closeReviewStep(vm.case_id, 'REVIEW_1',
                        vm.slide_id, vm.reviewNotes)
                        .then(closeReviewSuccessFn, closeReviewErrorFn);

                    //noinspection JSAnnotator
                    function closeReviewSuccessFn(response) {
                        // review closed, go back to case worklist
                        $location.url('worklist/' + vm.case_id);
                    }

                    //noinspection JSAnnotator
                    function closeReviewErrorFn(response) {
                        console.error(response.error);
                    }
                }
            }

            function qualityControlCreationErrorFn(response) {
                console.error(response);
            }
        }
    }
})();<commit_msg>Fixes crs4/ProMort#19<commit_after>(function () {
    'use strict';

    angular
        .module('promort.slides_manager.controllers')
        .controller('QualityControlController', QualityControlController);

    QualityControlController.$inject = ['$scope', '$routeParams', '$location',
        'SlideService', 'QualityControlService', 'ReviewStepsService'];

    function QualityControlController($scope, $routeParams, $location, SlideService,
                                      QualityControlService, ReviewStepsService) {
        var vm = this;
        vm.slide_id = undefined;
        vm.case_id = undefined;
        vm.stainings = undefined;
        vm.not_adequacy_reasons = undefined;
        vm.checkStainingFormSubmission = checkStainingFormSubmission;
        vm.checkQCFormSubmission = checkQCFormSubmission;
        vm.submitStaining = submitStaining;
        vm.submitQualityControl = submitQualityControl;

        vm.slideStainingSubmitted = false;
        vm.slideStaining = undefined;
        vm.slideQualityControl = {};
        vm.reviewNotes = '';

        activate();

        function activate() {
            vm.slide_id = $routeParams.slide;
            vm.case_id = $routeParams.case;
            SlideService.get(vm.slide_id)
                .then(getSlideSuccessFn, getSlideErrorFn);

            function getSlideSuccessFn(response) {
                if (response.data.quality_control === null) {
                    // initialize not_adequacy_reason
                    QualityControlService.fetchNotAdequacyReasons()
                        .then(fetchNotAdequacyReasonSuccessFn);
                    //noinspection JSAnnotator
                    function fetchNotAdequacyReasonSuccessFn(response) {
                        vm.not_adequacy_reasons = response.data;
                    }
                    //initialize staining
                    SlideService.fetchStainings()
                        .then(fetchStainingSuccessFn);
                    //noinspection JSAnnotator
                    function fetchStainingSuccessFn(response) {
                        vm.stainings = response.data;
                    }
                    if (response.data.staining !== null) {
                        vm.slideStaining = response.data.staining;
                        vm.slideStainingSubmitted = true;
                    }
                } else {
                    if (response.data.quality_control.adequate_slide) {
                        $location.url('worklist/' + vm.case_id + '/' + vm.slide_id + '/rois_manager');
                    } else {
                        $location.url('worklist/' + vm.case_id);
                    }
                }
            }

            function getSlideErrorFn(response) {
                console.error('Cannot load slide info');
                console.error(response);
            }
        }

        function checkStainingFormSubmission() {
            return !(typeof vm.slideStaining === 'undefined');
        }

        function checkQCFormSubmission() {
            if (!vm.slideStainingSubmitted) {
                return false;
            }
            if (vm.slideQualityControl.goodImageQuality &&
                vm.slideQualityControl.goodImageQuality === 'true') {
                return true;
            }
            if (vm.slideQualityControl.goodImageQuality &&
                vm.slideQualityControl.goodImageQuality === 'false' &&
                vm.slideQualityControl.notAdequacyReason) {
                return true;
            }
            return false;
        }

        function submitStaining() {
            SlideService.updateSliceStaining(
                vm.slide_id,
                vm.slideStaining
            ).then(slideStainingUpdateSuccessFn, slideStainingUpdateErrorFn);

            function slideStainingUpdateSuccessFn(response) {
                vm.slideStainingSubmitted = true;
            }

            function slideStainingUpdateErrorFn(response) {
                console.error('Unable to update slide staining');
                console.error(response);
            }
        }

        function submitQualityControl() {
            QualityControlService.create(
                vm.slide_id,
                $.parseJSON(vm.slideQualityControl.goodImageQuality),
                vm.slideQualityControl.notAdequacyReason
            ).then(qualityControlCreationSuccessFn, qualityControlCreationErrorFn);

            function qualityControlCreationSuccessFn(response) {
                if(vm.slideQualityControl.goodImageQuality === 'true') {
                    $location.url('worklist/' + vm.case_id + '/' + vm.slide_id + '/rois_manager');
                } else {
                    // close the review because image quality is bad
                    ReviewStepsService.closeReviewStep(vm.case_id, 'REVIEW_1',
                        vm.slide_id, vm.reviewNotes)
                        .then(closeReviewSuccessFn, closeReviewErrorFn);

                    //noinspection JSAnnotator
                    function closeReviewSuccessFn(response) {
                        // review closed, go back to case worklist
                        $location.url('worklist/' + vm.case_id);
                    }

                    //noinspection JSAnnotator
                    function closeReviewErrorFn(response) {
                        console.error(response.error);
                    }
                }
            }

            function qualityControlCreationErrorFn(response) {
                console.error(response);
            }
        }
    }
})();<|endoftext|>


<commit_before>/*************************************************
 * Copyright (c) 2015 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/

 /**
 * @ngdoc function
 * @name forms.function:CustomInventory
 * @description This form is for adding/editing an organization
*/

export default function() {
    return {

        addTitle: 'New Notification Template',
        editTitle: '{{ name }}',
        name: 'notifier',
        showActions: true,
        subFormTitles: {
            typeSubForm: 'Type Details',
        },

        fields: {
            name: {
                label: 'Name',
                type: 'text',
                addRequired: true,
                editRequired: true,
                capitalize: false
            },
            description: {
                label: 'Description',
                type: 'text',
                addRequired: false,
                editRequired: false
            },
            organization: {
                label: 'Organization',
                type: 'lookup',
                sourceModel: 'organization',
                sourceField: 'name',
                ngClick: 'lookUpOrganization()',
                awRequiredWhen: {
                    variable: "organizationrequired",
                    init: "true"
                }
            },
            notification_type: {
                label:  'Type',
                type: 'select',
                addRequired: true,
                editRequired: true,
                class: 'NotificationsForm-typeSelect prepend-asterisk',
                ngOptions: 'type.label for type in notification_type_options track by type.value',
                ngChange: 'typeChange()',
                hasSubForm: true
            },
            username: {
                label: 'Username',
                type: 'text',
                awRequiredWhen: {
                    variable: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            use_tls: {
                label: 'Use TLS',
                type: 'checkbox',
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            host: {
                label: 'Host',
                type: 'text',
                awRequiredWhen: {
                    variable: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            sender: {
                label: 'Sender Email',
                type: 'text',
                awRequiredWhen: {
                    variable: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            recipients: {
                label: 'Recipient List',
                type: 'textarea',
                rows: 3,
                awPopOver: '
Type an option on each line.
'+
                            '
For example:
alias1@email.com
\n alias2@email.com
\n',
                dataTitle: 'Recipient List',
                dataPlacement: 'right',
                dataContainer: "body",
                awRequiredWhen: {
                    variable: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            password: {
                labelBind: 'passwordLabel',
                type: 'sensitive',
                hasShowInputButton: true,
                awRequiredWhen: {
                    variable: "password_required" ,
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            use_ssl: {
                labelBind: 'sslLabel',
                type: 'checkbox',
                ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            port: {
                labelBind: 'portLabel',
                type: 'number',
                integer: true,
                spinner: true,
                'class': "input-small",
                min: 0,
                awRequiredWhen: {
                    variable: "port_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' || notification_type.value == 'irc'",
                subForm: 'typeSubForm'
            },
            channels: {
                label: 'Destination Channels',
                type: 'textarea',
                rows: 3,
                awPopOver: '
Type an option on each line. The pound symbol (#) is not required.
'+
                            '
For example:
engineering
\n support
\n',
                dataTitle: 'Destination Channels',
                dataPlacement: 'right',
                dataContainer: "body",
                awRequiredWhen: {
                    variable: "channel_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'slack' || notification_type.value == 'hipchat'",
                subForm: 'typeSubForm'
            },
            token: {
                labelBind: 'tokenLabel',
                type: 'sensitive',
                hasShowInputButton: true,
                awRequiredWhen: {
                    variable: "token_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'slack' || notification_type.value == 'pagerduty' || notification_type.value == 'hipchat'",
                subForm: 'typeSubForm'
            },
            account_token: {
                label: 'Account Token',
                type: 'sensitive',
                hasShowInputButton: true,
                awRequiredWhen: {
                    variable: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            from_number: {
                label: 'Source Phone Number',
                type: 'text',
                awRequiredWhen: {
                    variable: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            to_numbers: {
                label: 'Destination SMS Number',
                type: 'textarea',
                rows: 3,
                awPopOver: '
Type an option on each line.
'+
                            '
For example:
alias1@email.com
\n alias2@email.com
\n',
                dataTitle: 'Destination Channels',
                dataPlacement: 'right',
                dataContainer: "body",
                awRequiredWhen: {
                    variable: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            account_sid: {
                label: 'Account SID',
                type: 'text',
                awRequiredWhen: {
                    variable: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            subdomain: {
                label: 'Pagerduty subdomain',
                type: 'text',
                awRequiredWhen: {
                    variable: "pagerduty_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'pagerduty' ",
                subForm: 'typeSubForm'
            },
            service_key: {
                label: 'API Service/Integration Key',
                type: 'text',
                awRequiredWhen: {
                    variable: "pagerduty_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'pagerduty' ",
                subForm: 'typeSubForm'
            },
            client_name: {
                label: 'Client Identifier',
                type: 'text',
                awRequiredWhen: {
                    variable: "pagerduty_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'pagerduty' ",
                subForm: 'typeSubForm'
            },
            message_from: {
                label: 'Label to be shown with notification',
                type: 'text',
                awRequiredWhen: {
                    variable: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            api_url: {
                label: 'API URL (e.g: https://mycompany.hiptchat.com)',
                type: 'text',
                awRequiredWhen: {
                    variable: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            color: {
                label: 'Notification Color',
                type: 'text',
                awRequiredWhen: {
                    variable: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            notify: {
                label: 'Notify Channel',
                type: 'text',
                awRequiredWhen: {
                    variable: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            url: {
                label: 'Target URL',
                type: 'text',
                awRequiredWhen: {
                    variable: "webhook_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'webhook' ",
                subForm: 'typeSubForm'
            },
            headers: {
                label: 'HTTP Headers',
                type: 'text',
                awRequiredWhen: {
                    variable: "webhook_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'webhook' ",
                subForm: 'typeSubForm'
            },
            server: {
                label: 'IRC Server Address',
                type: 'text',
                awRequiredWhen: {
                    variable: "irc_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            nickname: {
                label: 'IRC Nick',
                type: 'text',
                awRequiredWhen: {
                    variable: "irc_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            targets: {
                label: 'Destination Channels or Users',
                type: 'text',
                awRequiredWhen: {
                    variable: "irc_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },

        },

        buttons: { //for now always generates <button> tags
            save: {
                ngClick: 'formSave()', //$scope.function to call on click, optional
                ngDisabled: true //Disable when $pristine or $invalid, optional
            },
            cancel: {
                ngClick: 'formCancel()',
            }
        }
    };
}
<commit_msg>Changed variable to reqExpression per the update to awRequiredWhen<commit_after>/*************************************************
 * Copyright (c) 2015 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/

 /**
 * @ngdoc function
 * @name forms.function:CustomInventory
 * @description This form is for adding/editing an organization
*/

export default function() {
    return {

        addTitle: 'New Notification Template',
        editTitle: '{{ name }}',
        name: 'notifier',
        showActions: true,
        subFormTitles: {
            typeSubForm: 'Type Details',
        },

        fields: {
            name: {
                label: 'Name',
                type: 'text',
                addRequired: true,
                editRequired: true,
                capitalize: false
            },
            description: {
                label: 'Description',
                type: 'text',
                addRequired: false,
                editRequired: false
            },
            organization: {
                label: 'Organization',
                type: 'lookup',
                sourceModel: 'organization',
                sourceField: 'name',
                ngClick: 'lookUpOrganization()',
                awRequiredWhen: {
                    reqExpression: "organizationrequired",
                    init: "true"
                }
            },
            notification_type: {
                label:  'Type',
                type: 'select',
                addRequired: true,
                editRequired: true,
                class: 'NotificationsForm-typeSelect prepend-asterisk',
                ngOptions: 'type.label for type in notification_type_options track by type.value',
                ngChange: 'typeChange()',
                hasSubForm: true
            },
            username: {
                label: 'Username',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            use_tls: {
                label: 'Use TLS',
                type: 'checkbox',
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            host: {
                label: 'Host',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            sender: {
                label: 'Sender Email',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            recipients: {
                label: 'Recipient List',
                type: 'textarea',
                rows: 3,
                awPopOver: '
Type an option on each line.
'+
                            '
For example:
alias1@email.com
\n alias2@email.com
\n',
                dataTitle: 'Recipient List',
                dataPlacement: 'right',
                dataContainer: "body",
                awRequiredWhen: {
                    reqExpression: "email_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' ",
                subForm: 'typeSubForm'
            },
            password: {
                labelBind: 'passwordLabel',
                type: 'sensitive',
                hasShowInputButton: true,
                awRequiredWhen: {
                    reqExpression: "password_required" ,
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            use_ssl: {
                labelBind: 'sslLabel',
                type: 'checkbox',
                ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            port: {
                labelBind: 'portLabel',
                type: 'number',
                integer: true,
                spinner: true,
                'class': "input-small",
                min: 0,
                awRequiredWhen: {
                    reqExpression: "port_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'email' || notification_type.value == 'irc'",
                subForm: 'typeSubForm'
            },
            channels: {
                label: 'Destination Channels',
                type: 'textarea',
                rows: 3,
                awPopOver: '
Type an option on each line. The pound symbol (#) is not required.
'+
                            '
For example:
engineering
\n support
\n',
                dataTitle: 'Destination Channels',
                dataPlacement: 'right',
                dataContainer: "body",
                awRequiredWhen: {
                    reqExpression: "channel_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'slack' || notification_type.value == 'hipchat'",
                subForm: 'typeSubForm'
            },
            token: {
                labelBind: 'tokenLabel',
                type: 'sensitive',
                hasShowInputButton: true,
                awRequiredWhen: {
                    reqExpression: "token_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'slack' || notification_type.value == 'pagerduty' || notification_type.value == 'hipchat'",
                subForm: 'typeSubForm'
            },
            account_token: {
                label: 'Account Token',
                type: 'sensitive',
                hasShowInputButton: true,
                awRequiredWhen: {
                    reqExpression: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            from_number: {
                label: 'Source Phone Number',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            to_numbers: {
                label: 'Destination SMS Number',
                type: 'textarea',
                rows: 3,
                awPopOver: '
Type an option on each line.
'+
                            '
For example:
alias1@email.com
\n alias2@email.com
\n',
                dataTitle: 'Destination Channels',
                dataPlacement: 'right',
                dataContainer: "body",
                awRequiredWhen: {
                    reqExpression: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            account_sid: {
                label: 'Account SID',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "twilio_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'twilio' ",
                subForm: 'typeSubForm'
            },
            subdomain: {
                label: 'Pagerduty subdomain',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "pagerduty_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'pagerduty' ",
                subForm: 'typeSubForm'
            },
            service_key: {
                label: 'API Service/Integration Key',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "pagerduty_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'pagerduty' ",
                subForm: 'typeSubForm'
            },
            client_name: {
                label: 'Client Identifier',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "pagerduty_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'pagerduty' ",
                subForm: 'typeSubForm'
            },
            message_from: {
                label: 'Label to be shown with notification',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            api_url: {
                label: 'API URL (e.g: https://mycompany.hiptchat.com)',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            color: {
                label: 'Notification Color',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            notify: {
                label: 'Notify Channel',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "hipchat_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'hipchat' ",
                subForm: 'typeSubForm'
            },
            url: {
                label: 'Target URL',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "webhook_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'webhook' ",
                subForm: 'typeSubForm'
            },
            headers: {
                label: 'HTTP Headers',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "webhook_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'webhook' ",
                subForm: 'typeSubForm'
            },
            server: {
                label: 'IRC Server Address',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "irc_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            nickname: {
                label: 'IRC Nick',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "irc_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },
            targets: {
                label: 'Destination Channels or Users',
                type: 'text',
                awRequiredWhen: {
                    reqExpression: "irc_required",
                    init: "false"
                },
                ngShow: "notification_type.value == 'irc' ",
                subForm: 'typeSubForm'
            },

        },

        buttons: { //for now always generates <button> tags
            save: {
                ngClick: 'formSave()', //$scope.function to call on click, optional
                ngDisabled: true //Disable when $pristine or $invalid, optional
            },
            cancel: {
                ngClick: 'formCancel()',
            }
        }
    };
}
<|endoftext|>


<commit_before>/**
 * Created by kevinkreuzer on 16.04.17.
 */
export default class ErrorLogService {

    constructor(){
        this.errors = [];

        //TODO kk - Just sample errors - remove after testing
        this.errors.push(this.createMockError(500, 'Internal server error'));
        this.errors.push(this.createMockError(404, 'Not found'));
        this.errors.push(this.createMockError(500, 'Internal server error'));
    }

    createMockError(code, message){
        return {code, message};
    }

    logError(errorMessage){
        this.errors.push(errorMessage);
    }
}
<commit_msg>kk: Added sample errors<commit_after>/**
 * Created by kevinkreuzer on 16.04.17.
 */
export default class ErrorLogService {

    constructor(){
        this.errors = [];

        //TODO kk - Just sample errors - remove as soon as error handling is implemented
        this.errors.push(this.createMockError(500, 'Sample Error 1'));
        this.errors.push(this.createMockError(404, 'Sample Error 2'));
        this.errors.push(this.createMockError(500, 'Sample Error 3'));
    }

    createMockError(code, message){
        return {code, message};
    }

    logError(errorMessage){
        this.errors.push(errorMessage);
    }
}
<|endoftext|>


<commit_before>(function (global) {
    'use strict';

    var app = global.app = global.app || {};

    app.PushFactory = (function () {
        var create = function (sender, recipients) {
            var filter;

            if (Array.isArray(recipients) && recipients.length > 0) {
                // filter on the userId field in each device
                filter = {
                    "User.Id": {
                        "$in": recipients
                    }
                };
            }
            // custom data object for Android and iOS
            var customData = {
                "dateCreated": new Date()
            };

            var pushTitle = "Backend Services Push Sample";
            var pushMessage = sender + ": " + "Hello, push notifications!";

            // construct the payload for the notification
            var generalPayload = {
                "Message": pushMessage
            };

            var androidPayload = {
                "data": {
                    "title": pushTitle,
                    "message": pushMessage,
                    "customData": customData
                }
            };

            var iosPayload = {
                "aps": {
                    "alert": pushMessage,
                    "badge": 1,
                    "sound": "default"
                },
                "customData": customData
            };

            var wpPayload = {
                "Toast": {
                    "Title": pushTitle,
                    "Message": pushMessage
                }
            };

            var notificationObject = {
                "Filter": JSON.stringify(filter),
                "Message": generalPayload,
                "Android": androidPayload,
                "IOS": iosPayload,
                "WindowsPhone": wpPayload
            };

            return notificationObject;
        }

        return {
            create: create
        }
    })();
}(window));<commit_msg>Removed the general payload for a platform.<commit_after>(function (global) {
    'use strict';

    var app = global.app = global.app || {};

    app.PushFactory = (function () {
        var create = function (sender, recipients) {
            var filter;

            if (Array.isArray(recipients) && recipients.length > 0) {
                // filter on the userId field in each device
                filter = {
                    "User.Id": {
                        "$in": recipients
                    }
                };
            }
            // custom data object for Android and iOS
            var customData = {
                "dateCreated": new Date()
            };

            var pushTitle = "Backend Services Push Sample";
            var pushMessage = sender + ": " + "Hello, push notifications!";

            // constructing the payload for the notification specifically for each supported mobile platform
            // following the structure from here: http://docs.telerik.com/platform/backend-services/features/push-notifications/structure
            var androidPayload = {
                "data": {
                    "title": pushTitle,
                    "message": pushMessage,
                    "customData": customData
                }
            };

            var iosPayload = {
                "aps": {
                    "alert": pushMessage,
                    "badge": 1,
                    "sound": "default"
                },
                "customData": customData
            };

            var wpPayload = {
                "Toast": {
                    "Title": pushTitle,
                    "Message": pushMessage
                }
            };

            var notificationObject = {
                "Filter": JSON.stringify(filter),
                "Android": androidPayload,
                "IOS": iosPayload,
                "WindowsPhone": wpPayload
            };

            return notificationObject;
        }

        return {
            create: create
        }
    })();
}(window));<|endoftext|>


<commit_before>'use strict';

/**
 * @ngdoc controller
 * @name core.controller:HeaderController
 *
 * @requires $cope
 * @requires module:users.service:Authentication
 * @requires core.service:Menus
 *
 * @description
 * Header controller
 */

angular.module('core').controller('HeaderController', ['$scope', 'Authentication', 'Menus',
	function($scope, Authentication, Menus) {
		$scope.authentication = Authentication;
		$scope.isCollapsed = false;

		// TODO Filter roles for admin link
		//if (typeof $scope.authentication.user.roles !== 'undefined' && $scope.authentication.user.roles.indexOf('admin') !== -1 ) {
		//	Menus.addMenuItem('topbar',  'Administrar a fuego', 'groupbuys/create');
		//}
		Menus.addMenuItem('topbar',  'Administrar a fuego', 'admin');

		$scope.menu = Menus.getMenu('topbar');

		/**
		* @ngdoc method
		* @name core.controller:HeaderController.$scope·toggleCollapsibleMenu
		* @methodOf core.controller:HeaderController
		*/
		$scope.toggleCollapsibleMenu = function() {
			$scope.isCollapsed = !$scope.isCollapsed;
		};

		// Collapsing the menu after navigation
		$scope.$on('$stateChangeSuccess', function() {
			$scope.isCollapsed = false;
		});
	}
]);<commit_msg>Fixed Typo<commit_after>'use strict';

/**
 * @ngdoc controller
 * @name core.controller:HeaderController
 *
 * @requires $cope
 * @requires module:users.service:Authentication
 * @requires core.service:Menus
 *
 * @description
 * Header controller
 */

angular.module('core').controller('HeaderController', ['$scope', 'Authentication', 'Menus',
	function($scope, Authentication, Menus) {
		$scope.authentication = Authentication;
		$scope.isCollapsed = false;

		// TODO Filter roles for admin link
		//if (typeof $scope.authentication.user.roles !== 'undefined' && $scope.authentication.user.roles.indexOf('admin') !== -1 ) {
		//	Menus.addMenuItem('topbar',  'Administrar', 'groupbuys/create');
		//}
		Menus.addMenuItem('topbar',  'Administrar', 'admin');

		$scope.menu = Menus.getMenu('topbar');

		/**
		* @ngdoc method
		* @name core.controller:HeaderController.$scope·toggleCollapsibleMenu
		* @methodOf core.controller:HeaderController
		*/
		$scope.toggleCollapsibleMenu = function() {
			$scope.isCollapsed = !$scope.isCollapsed;
		};

		// Collapsing the menu after navigation
		$scope.$on('$stateChangeSuccess', function() {
			$scope.isCollapsed = false;
		});
	}
]);<|endoftext|>


<commit_before>'use strict';

// Music controller
angular.module('music').controller('MusicController', ['$scope', '$stateParams', '$location', 'Authentication', 'Music',
	function($scope, $stateParams, $location, Authentication, Music) {
		$scope.authentication = Authentication;

		// Create new Music
		$scope.create = function() {
			// Create new Music object
			var music = new Music ({
				name: this.name,
                                path: this.path,
                                title: this.title,
                                instrument: this.instrument
			});

			// Redirect after save
			music.$save(function(response) {
				$location.path('music/' + response._id);

				// Clear form fields
				$scope.name = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Remove existing Music
		$scope.remove = function(music) {
			if ( music ) {
				music.$remove();

				for (var i in $scope.music) {
					if ($scope.music [i] === music) {
						$scope.music.splice(i, 1);
					}
				}
			} else {
				$scope.music.$remove(function() {
					$location.path('music');
				});
			}
		};

		// Update existing Music
		$scope.update = function() {
			var music = $scope.music;

			music.$update(function() {
				$location.path('music/' + music._id);
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Find a list of Music
		$scope.find = function() {
			$scope.music = Music.query();
		};

		// Find existing Music
		$scope.findOne = function() {
			$scope.music = Music.get({
				musicId: $stateParams.musicId
			});
		};

	}
]);<commit_msg>added instruments to music controlelrrererer<commit_after>'use strict';

// Music controller
angular.module('music').controller('MusicController', ['$scope', '$stateParams', '$location', 'Authentication', 'Music',
	function($scope, $stateParams, $location, Authentication, Music) {
		$scope.authentication = Authentication;

                $scope.instruments = ['piccolo', 'flute', 'clarinet', 'oboe', 'english horn', 'basson', 'contrabass',
		'contrabass bassoon', 'alto saxophone', 'tenor saxophone','baritone saxophone',
		'french horn', 'horn', 'mellophone','trumpet', 'cornet', 'baritone', 'euphonium', 'trombone',
		'bass trombone', 'tuba', 'sousaphone', 'string bass', 'bass', 'bass guitar', 'guitar',
		'percussion', 'bass drum', 'quads', 'tenors', 'snare', 'cymbals', 'triangle', 'timpani',
		'marimba', 'vibraphone', 'xylophone', 'glockenspiel', 'drumset',
		'celeste', 'celesta', 'piano', 'harp', 'bongos'];
                $scope.instruments.sort();

		// Create new Music
		$scope.create = function() {
			// Create new Music object
			var music = new Music ({
				name: this.name,
                                path: this.path,
                                title: this.title,
                                instrument: this.instrument
			});

			// Redirect after save
			music.$save(function(response) {
				$location.path('music/' + response._id);

				// Clear form fields
				$scope.name = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Remove existing Music
		$scope.remove = function(music) {
			if ( music ) {
				music.$remove();

				for (var i in $scope.music) {
					if ($scope.music [i] === music) {
						$scope.music.splice(i, 1);
					}
				}
			} else {
				$scope.music.$remove(function() {
					$location.path('music');
				});
			}
		};

		// Update existing Music
		$scope.update = function() {
			var music = $scope.music;

			music.$update(function() {
				$location.path('music/' + music._id);
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Find a list of Music
		$scope.find = function() {
			$scope.music = Music.query();
		};

		// Find existing Music
		$scope.findOne = function() {
			$scope.music = Music.get({
				musicId: $stateParams.musicId
			});
		};

	}
]);<|endoftext|>


<commit_before>// This file is part of BenchExec, a framework for reliable benchmarking:
// https://github.com/sosy-lab/benchexec
//
// SPDX-FileCopyrightText: 2019-2020 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0

// enzyme
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
window.crypto = require("@trust/webcrypto");

// mock uniqid to have consistent names
// https://stackoverflow.com/a/44538270/396730
jest.mock("uniqid", () => (i) => i + "uniqid");

configure({ adapter: new Adapter() });
<commit_msg>Add comment for attaching of crypto<commit_after>// This file is part of BenchExec, a framework for reliable benchmarking:
// https://github.com/sosy-lab/benchexec
//
// SPDX-FileCopyrightText: 2019-2020 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0

// enzyme
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
// Used by @zip.js/zip.js, but not implemented in jsdom via jest, so manually add it here
window.crypto = require("@trust/webcrypto");

// mock uniqid to have consistent names
// https://stackoverflow.com/a/44538270/396730
jest.mock("uniqid", () => (i) => i + "uniqid");

configure({ adapter: new Adapter() });
<|endoftext|>


<commit_before>'use strict';

// Todos controller
angular.module('todos').controller('TodosController', ['$scope', '$http', '$stateParams', '$location', 'Authentication', 'Todos',
	function($scope, $http, $stateParams, $location, Authentication, Todos) {
		$scope.authentication = Authentication;

		// Create new Todo
		$scope.create = function(fromListInput) {
			// Create new Todo object
			console.log('name', this.name);
			var todo = new Todos ({
				name: this.name,
				created_by: $scope.authentication.user.displayName,
				wg_id: $scope.authentication.user.wg_id
			});

			// Redirect after save
			todo.$save(function(response) {
				$location.path('todos');
				if(fromListInput){
					$scope.todos.push(response);
				}
				// Clear form fields
				$scope.name = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Remove existing Todo
		$scope.remove = function(todo) {
			if ( todo ) {
				todo.$remove();

				for (var i in $scope.todos) {
					if ($scope.todos [i] === todo) {
						$scope.todos.splice(i, 1);
					}
				}
			} else {
				$scope.todo.$remove(function() {
					$location.path('todos');
				});
			}
		};

		// Update existing Todo
		$scope.update = function() {
			var todo = $scope.todo;

			todo.$update(function() {
				$location.path('todos/' + todo._id);
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Find a list of Todos
		$scope.find = function() {
			$scope.removeBgClass();
			$scope.todos = Todos.query();
		};

		$scope.getAll = function(){
			$scope.removeBgClass();
			$http.get('/todo/all-from-share').success(function(res){
				$scope.todos = res;
			}).error(function(err){
				console.log('error at get', err);
				$scope.error = err.message;
			});
		};

		// Find existing Todo
		$scope.findOne = function() {
			$scope.removeBgClass();
			$scope.todo = Todos.get({
				todoId: $stateParams.todoId
			});
		};

		$scope.setToDone = function(index,todo){
			console.log('settoDone');
			if(!$scope.todos[index].isDone){
				var path = '/todos/' + todo._id;
				var item = todo;
				item.isDone = true;
				item.done_when = new Date();
				item.done_by = $scope.authentication.user.displayName;
				$http.put(path, item).success(function(res){
					$scope.todos[index] = item;
				}).error(function(err){
					$scope.error = err.message;
				})

			}
		};

		$scope.removeBgClass = function(){
			document.body.style.background = '#fff';
		};
	}
]);
<commit_msg>feat: add new todo front<commit_after>'use strict';

// Todos controller
angular.module('todos').controller('TodosController', ['$scope', '$http', '$stateParams', '$location', 'Authentication', 'Todos',
	function($scope, $http, $stateParams, $location, Authentication, Todos) {
		$scope.authentication = Authentication;

		// Create new Todo
		$scope.create = function(fromListInput) {
			// Create new Todo object
			console.log('name', this.name);
			var todo = new Todos ({
				name: this.name,
				created_by: $scope.authentication.user.displayName,
				wg_id: $scope.authentication.user.wg_id
			});

			// Redirect after save
			todo.$save(function(response) {
				$location.path('todos');
				if(fromListInput){
					$scope.todos.unshift(response);
				}
				// Clear form fields
				$scope.name = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Remove existing Todo
		$scope.remove = function(todo) {
			if ( todo ) {
				todo.$remove();

				for (var i in $scope.todos) {
					if ($scope.todos [i] === todo) {
						$scope.todos.splice(i, 1);
					}
				}
			} else {
				$scope.todo.$remove(function() {
					$location.path('todos');
				});
			}
		};

		// Update existing Todo
		$scope.update = function() {
			var todo = $scope.todo;

			todo.$update(function() {
				$location.path('todos/' + todo._id);
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Find a list of Todos
		$scope.find = function() {
			$scope.removeBgClass();
			$scope.todos = Todos.query();
		};

		$scope.getAll = function(){
			$scope.removeBgClass();
			$http.get('/todo/all-from-share').success(function(res){
				$scope.todos = res;
			}).error(function(err){
				console.log('error at get', err);
				$scope.error = err.message;
			});
		};

		// Find existing Todo
		$scope.findOne = function() {
			$scope.removeBgClass();
			$scope.todo = Todos.get({
				todoId: $stateParams.todoId
			});
		};

		$scope.setToDone = function(index,todo){
			console.log('settoDone');
			if(!$scope.todos[index].isDone){
				var path = '/todos/' + todo._id;
				var item = todo;
				item.isDone = true;
				item.done_when = new Date();
				item.done_by = $scope.authentication.user.displayName;
				$http.put(path, item).success(function(res){
					$scope.todos[index] = item;
				}).error(function(err){
					$scope.error = err.message;
				})

			}
		};

		$scope.removeBgClass = function(){
			document.body.style.background = '#fff';
		};
	}
]);
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
var gutil = require("gulp-util");
var webpack = require('webpack');
var compass = require('gulp-compass');
var minifycss = require('gulp-minify-css');
var rename = require('gulp-rename');
var notifier = require('node-notifier');
var uglify = require('gulp-uglify');

gulp.task('build-sass', function() {
  return gulp.src(['sass/*.scss', 'sass/**/*.scss'])
    .pipe(compass({
      css: '../css',
      sass: 'sass',
      image: '../img'
    }))
    .on('error', function(error){
      notifier.notify({
        title: error.plugin,
        message: error.message
      });
      this.emit('end');
    })
    .pipe(gulp.dest('../css'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(minifycss())
    .pipe(gulp.dest('../css'))
    ;
});

gulp.task('watch-sass', function() {
  gulp.watch(['sass/*.scss', 'sass/**/*.scss'], ['build-sass']);
});

gulp.task('build-scaffold', function() {
  var config = require('./js/scaffold/webpack.config.js');
  webpack(config, function(err, stats) {
    //notifier
    if (stats.compilation.errors.length) {
      notifier.notify({
        title: 'Webpack',
        message: stats.compilation.errors[0].message
      });
    }

    //console log
    gutil.log("[webpack]", stats.toString({}));

    //uglify
    gulp.src(config.output.path + '/' + config.output.filename)
      .pipe(rename({ suffix: '.min' }))
      .pipe(uglify({
        preserveComments: 'license'
      }))
      .pipe(gulp.dest('../js'))
  });
});

gulp.task('scaffold', ['build-scaffold', 'watch-sass']);<commit_msg>webpackを使わないjsのgulpを追加<commit_after>'use strict';

var gulp = require('gulp');
var gutil = require("gulp-util");
var webpack = require('webpack');
var compass = require('gulp-compass');
var minifycss = require('gulp-minify-css');
var rename = require('gulp-rename');
var notifier = require('node-notifier');
var uglify = require('gulp-uglify');

gulp.task('build-sass', function() {
  return gulp.src(['sass/*.scss', 'sass/**/*.scss'])
    .pipe(compass({
      css: '../css',
      sass: 'sass',
      image: '../img'
    }))
    .on('error', function(error){
      notifier.notify({
        title: error.plugin,
        message: error.message
      });
      this.emit('end');
    })
    .pipe(gulp.dest('../css'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(minifycss())
    .pipe(gulp.dest('../css'))
    ;
});

gulp.task('watch-sass', function() {
  gulp.watch(['sass/*.scss', 'sass/**/*.scss'], ['build-sass']);
});

gulp.task('build-scaffold', function() {
  var config = require('./js/scaffold/webpack.config.js');
  webpack(config, function(err, stats) {
    //notifier
    if (stats.compilation.errors.length) {
      notifier.notify({
        title: 'Webpack',
        message: stats.compilation.errors[0].message
      });
    }

    //console log
    gutil.log("[webpack]", stats.toString({}));

    //uglify
    gulp.src(config.output.path + '/' + config.output.filename)
      .pipe(rename({ suffix: '.min' }))
      .pipe(uglify({
        preserveComments: 'license'
      }))
      .pipe(gulp.dest('../js'))
  });
});

// js/static内のファイルをコピーしてなおかつuglifyする。
var staticSources = [ 'js/static/*.js', 'js/static/**/*.js' ];
gulp.task('copy-static', function(){

  gulp.src(staticSources, { base: 'js/static' })
    .pipe( gulp.dest( '../js/static' ));

  gulp.src(staticSources, { base: 'js/static' })
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify({
      preserveComments: 'license'
    }))
    .pipe(gulp.dest('../js/static'))
});

gulp.task('watch-static', function(){
  gulp.watch(staticSources, ['copy-static']);
})

gulp.task('scaffold', ['build-scaffold', 'watch-sass', 'watch-static']);<|endoftext|>