<commit_before>//Nodig voor autoincrement
var selectedcourseid;
var studid;
var worksheets = [];
var worksheetsid = [];

//viewmodel for the assess page
function pageViewModel(gvm) {
    gvm.app  = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectRapportName")}, gvm);
    gvm.title = ko.computed(function(){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n. __("AssessTitle2");}, gvm);
    gvm.userId = -1;

    // Page specific i18n bindings
    gvm.pageHeader = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("AssessTitle2");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectRapportName");}, gvm);
    gvm.homeManual = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("HomeRapportManual");}, gvm);
    gvm.foundProjects = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("FoundProjects");}, gvm);
    gvm.selectCourse = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("SelectCourse");}, gvm);

    // Pagination i18n bindings
    gvm.addBtn = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("AddBtn")}, gvm);

    // Table i18n bindings
    gvm.werkficheID = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheID");}, gvm);
    gvm.werkficheName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheName");}, gvm);
    gvm.werkficheDate = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheDate");}, gvm);
    gvm.werkficheAction = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheAction");}, gvm);

    gvm.availableCourses = ko.observableArray([]);
    gvm.availableStudentlists = ko.observableArray([]);
    gvm.availableStudents = ko.observableArray([]);

    gvm.currentCourseId = null;
    gvm.currentStudentlistId = null;
    gvm.currentStudentId = null;

    gvm.updateDropdowns = function() {
        $.getJSON('api/lastdropdownrapporten/' + gvm.userId, function(data) {
            if(!$.isEmptyObject(data)) {
                $.each(data, function(i, item) {
                    $(".btn-courseRapport span:first").text(item.course);
                    $(".btn-studentlist span:first").text(item.studentlist);
                    $('.btn-student span:first').text(item.student);
                    gvm.currentCourseId = item.courseid;
                    selectedcourseid = item.courseid;
                    gvm.updateStudentlists(item.courseid, gvm.userId);
                    gvm.currentStudentlistId = item.studentlistid;
                    gvm.updateStudents(item.studentlistid);
                    gvm.currentStudentId = item.studentid;
                    studid = item.studentid;
                    gvm.updateCourseRapport();
                    loadTablePage(item.courseid, 1);
                });
            } else {
                gvm.updateCourseRapport();
            }
        });
    }

    //Houdt bij wat geselecteerd wordt
    //Wordt opgeroepen bij iedere wijziging (niet ingevulde velden = NULL)
    gvm.saveLastSelectedDropdowns = function() {
        data = {};
        data["user"] = gvm.userId;
        data["course"] = $(".btn-courseRapport span:first").text();
        data["courseid"] = gvm.currentCourseId;
        data["studentlist"] = $('.btn-studentlist span:first').text();
        data["studentlistid"] = gvm.currentStudentlistId;
        data["student"] = $(".btn-student span:first").text();
        data["studentid"] = gvm.currentStudentId;
        studid = gvm.currentStudentId;
        $.ajax({
            type: "POST",
            url: "/api/savedropdownsRapport",
            data: data,
            success: function() {
                console.log("success");
            }
        })
    }

    gvm.updateCourseRapport = function() {
        $.getJSON('/api/coursefromteacher/' + gvm.userId, function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                //  Put item in list
                gvm.availableCourses.push(item);

                // Add listener to listitem
                $("#coursebtn-" + item.id).click(function(){
                    gvm.currentCourseId = item.id;
                    selectedcourseid = item.id;
                    gvm.currentStudentlistId = null;
                    gvm.currentStudentId = null;
                    gvm.updateStudentlists(item.id, gvm.userId);
                    $(".btn-courseRapport span:first").text($(this).text());
                    $(".btn-studentlist span:first").text("Studentlist");
                    $('.btn-student span:first').text("Student");
                    gvm.saveLastSelectedDropdowns();
                });
            });
        });
    };

    /*
     * Update the student data
     */
    gvm.updateStudentlists = function(cid, uid) {
        //get all studentlists
        $.getJSON('api/studentlistdrop/' + cid + '/' + uid, function(data) {
            gvm.availableStudentlists.removeAll();
            $.each(data, function(i,item) {
                // Put item in list
                gvm.availableStudentlists.push(item);

                // Add listener to listitem
                $("#studentlistbtn-" + item.id).click(function(){
                    gvm.currentStudentlistId = item.id;
                    gvm.currentStudentId = null;
                    gvm.updateStudents(item.id);
                    $(".btn-studentlist span:first").text($(this).text());
                    $('.btn-student span:first').text("Student");
                    gvm.saveLastSelectedDropdowns();
                });
            })
        })
    }

    /*
     * Update the student data
     */
    gvm.updateStudents = function(id) {
        //get all students who follow that course
        $.getJSON('api/studentdrop/' + id, function(data) {
            gvm.availableStudents.removeAll();
            $.each(data, function(i,item) {
                // Put item in list
                gvm.availableStudents.push(item);

                // Add listener to listitem
                $("#studentbtn-" + item.id).click(function(){
                    gvm.currentStudentId = item.id;
                    $(".btn-student span:first").text($(this).text());
                    gvm.saveLastSelectedDropdowns();
                });
            })
        })
    }

    // The table data observable array
    gvm.tabledata = ko.observableArray([]);

    // Add data to the table
    gvm.addTableData = function(id, name, lastname, mail, score) {
        // Push data
        var tblOject = {tstudid: id, tname: name, tlname: lastname, tmail: mail, tscore: score};
        gvm.tabledata.push(tblOject);
    }

    gvm.clearTable = function() {
        gvm.tabledata.removeAll();
    }
}

function getAllWorksheets() {
    worksheets = [];
    worksheetsid = [];
    $.getJSON('/api/worksheets/' + selectedcourseid, function(data) {
        $.each(data, function(i, item) {
            worksheets.push(item.Name);
            worksheetsid.push(item.id);
        });
    });
    return worksheets;
}

function getWorksheetid() {
    var i = 0;
    var worksheet = 0;
    worksheets.forEach(function(entry) {
        if (new String(entry).valueOf() == new String($('#worksheetComplete').val()).valueOf()) {
            worksheet = worksheetsid[i];
        }
        i+= 1;
    });
    return worksheet;
}

function addWorksheet(worksheetid) {
    console.log("toe te voegenworksheet " + worksheetid + " voor " + studid);
    $.ajax({
        url: "/api/worksheetstudentcouple/" + worksheetid + "/" + studid,
        type: "POST",
        data: {'worksheetid': worksheetid, 'studid': studid},
        success: function(data) {
            //callback(true);
        },
        error: function(data) {
            console.log('Failed to add new student');
            //callback(false);
        }
    });
}

function loadTablePage(pagenr)
{
    $.getJSON('/api/worksheets/page/' + pagenr, function(data){

        /* Clear current table page */
        viewModel.clearTable();

        // Load table data
        $.each(data.data, function(i, item) {
            viewModel.addTableData(item.id,  item.firstname, item.lastname, item.mail);
        });

        /* Let previous en next buttons work */
        if(data.prev == "none"){
            $('#pager-prev-btn').addClass('disabled');
        } else {
            $('#pager-prev-btn').removeClass('disabled');
            $('#pager-prev-btn a').click(function(){
                loadTablePage(data.prev);
            });
        }

        if(data.next == "none"){
            $('#pager-next-btn').addClass('disabled');
        } else {
            $('#pager-next-btn').removeClass('disabled');
            $('#pager-next-btn a').click(function(){
                loadTablePage(data.next);
            });
        }

        // Number of pager buttons
        var numItems = $('.pager-nr-btn').length;

        /* Calculate for the pager buttons */
        var lowPage = Math.floor(pagenr/numItems) + 1;

        $('.pager-nr-btn').each(function() {
            /* calculate current page number */
            var thispagenr = lowPage++;

            /* Add the page number */
            $(this).html('' + thispagenr + '');

            /* Add active class to current page */
            if(thispagenr == pagenr) {
                $(this).addClass('active');
            } else {
                $(this).removeClass('active');
            }

            /* Disable inactive classes and bind handlers to active classes */
            if(thispagenr > data.pagecount) {
                $(this).addClass('disabled');
            } else {
                /* Add click listener for button */
                $(this).click(function() {
                    loadTablePage(thispagenr);
                });
            }
        });
    });
}

function initPage() {
    $.getJSON('/api/currentuser', function(data) {
        viewModel.userId = data.id;
        viewModel.updateDropdowns();
    });

    $('#addGroupForm').hide();

    $('#addWorksheetBtn').click(function() {
        $("#addGroupForm").show();
        $('#worksheetComplete').autocomplete({ source: getAllWorksheets() });
    });

    $('#addNewWorksheetBtn').click(function() {
        //TODO controle of er effectief een lijst / student geselecteerd is.
        console.log("geselecteerd " + $('#studentenradio').val())
        //controleren of het voor 1 student is of voor alle studenten
        if (new String ($('#studentenradio').val()) == new String("student")) {
            console.log("Add student");
            addWorksheet(getWorksheetid());
        }
            else if (new String ($('#studentenradio').val()) == new String("studentlist"))//studentlist
        {
            console.log("Add studentengroep");
        }
        else {
        console.log("Niets geselecteerd");
        }
        //table opnieuw laden
        loadTablePage(1);

        //Indien gewenst toevoegformulier weer verbergen.
        $('#worksheetComplete').val("");
        $('#addGroupForm').hide();
    });
}<commit_msg>Keuze geven tussen studentenlijst of enkele student<commit_after>//Nodig voor autoincrement
var selectedcourseid;
var studid;
var worksheets = [];
var worksheetsid = [];

//viewmodel for the assess page
function pageViewModel(gvm) {
    gvm.app  = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectRapportName")}, gvm);
    gvm.title = ko.computed(function(){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n. __("AssessTitle2");}, gvm);
    gvm.userId = -1;

    // Page specific i18n bindings
    gvm.pageHeader = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("AssessTitle2");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectRapportName");}, gvm);
    gvm.homeManual = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("HomeRapportManual");}, gvm);
    gvm.foundProjects = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("FoundProjects");}, gvm);
    gvm.selectCourse = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("SelectCourse");}, gvm);

    // Pagination i18n bindings
    gvm.addBtn = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("AddBtn")}, gvm);

    // Table i18n bindings
    gvm.werkficheID = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheID");}, gvm);
    gvm.werkficheName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheName");}, gvm);
    gvm.werkficheDate = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheDate");}, gvm);
    gvm.werkficheAction = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheAction");}, gvm);

    gvm.availableCourses = ko.observableArray([]);
    gvm.availableStudentlists = ko.observableArray([]);
    gvm.availableStudents = ko.observableArray([]);

    gvm.currentCourseId = null;
    gvm.currentStudentlistId = null;
    gvm.currentStudentId = null;

    gvm.updateDropdowns = function() {
        $.getJSON('api/lastdropdownrapporten/' + gvm.userId, function(data) {
            if(!$.isEmptyObject(data)) {
                $.each(data, function(i, item) {
                    $(".btn-courseRapport span:first").text(item.course);
                    $(".btn-studentlist span:first").text(item.studentlist);
                    $('.btn-student span:first').text(item.student);
                    gvm.currentCourseId = item.courseid;
                    selectedcourseid = item.courseid;
                    gvm.updateStudentlists(item.courseid, gvm.userId);
                    gvm.currentStudentlistId = item.studentlistid;
                    gvm.updateStudents(item.studentlistid);
                    gvm.currentStudentId = item.studentid;
                    studid = item.studentid;
                    gvm.updateCourseRapport();
                    loadTablePage(item.courseid, 1);
                });
            } else {
                gvm.updateCourseRapport();
            }
        });
    }

    //Houdt bij wat geselecteerd wordt
    //Wordt opgeroepen bij iedere wijziging (niet ingevulde velden = NULL)
    gvm.saveLastSelectedDropdowns = function() {
        data = {};
        data["user"] = gvm.userId;
        data["course"] = $(".btn-courseRapport span:first").text();
        data["courseid"] = gvm.currentCourseId;
        data["studentlist"] = $('.btn-studentlist span:first').text();
        data["studentlistid"] = gvm.currentStudentlistId;
        data["student"] = $(".btn-student span:first").text();
        data["studentid"] = gvm.currentStudentId;
        studid = gvm.currentStudentId;
        $.ajax({
            type: "POST",
            url: "/api/savedropdownsRapport",
            data: data,
            success: function() {
                console.log("success");
            }
        })
    }

    gvm.updateCourseRapport = function() {
        $.getJSON('/api/coursefromteacher/' + gvm.userId, function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                //  Put item in list
                gvm.availableCourses.push(item);

                // Add listener to listitem
                $("#coursebtn-" + item.id).click(function(){
                    gvm.currentCourseId = item.id;
                    selectedcourseid = item.id;
                    gvm.currentStudentlistId = null;
                    gvm.currentStudentId = null;
                    gvm.updateStudentlists(item.id, gvm.userId);
                    $(".btn-courseRapport span:first").text($(this).text());
                    $(".btn-studentlist span:first").text("Studentlist");
                    $('.btn-student span:first').text("Student");
                    gvm.saveLastSelectedDropdowns();
                });
            });
        });
    };

    /*
     * Update the student data
     */
    gvm.updateStudentlists = function(cid, uid) {
        //get all studentlists
        $.getJSON('api/studentlistdrop/' + cid + '/' + uid, function(data) {
            gvm.availableStudentlists.removeAll();
            $.each(data, function(i,item) {
                // Put item in list
                gvm.availableStudentlists.push(item);

                // Add listener to listitem
                $("#studentlistbtn-" + item.id).click(function(){
                    gvm.currentStudentlistId = item.id;
                    gvm.currentStudentId = null;
                    gvm.updateStudents(item.id);
                    $(".btn-studentlist span:first").text($(this).text());
                    $('.btn-student span:first').text("Student");
                    gvm.saveLastSelectedDropdowns();
                });
            })
        })
    }

    /*
     * Update the student data
     */
    gvm.updateStudents = function(id) {
        //get all students who follow that course
        $.getJSON('api/studentdrop/' + id, function(data) {
            gvm.availableStudents.removeAll();
            $.each(data, function(i,item) {
                // Put item in list
                gvm.availableStudents.push(item);

                // Add listener to listitem
                $("#studentbtn-" + item.id).click(function(){
                    gvm.currentStudentId = item.id;
                    $(".btn-student span:first").text($(this).text());
                    gvm.saveLastSelectedDropdowns();
                });
            })
        })
    }

    // The table data observable array
    gvm.tabledata = ko.observableArray([]);

    // Add data to the table
    gvm.addTableData = function(id, name, lastname, mail, score) {
        // Push data
        var tblOject = {tstudid: id, tname: name, tlname: lastname, tmail: mail, tscore: score};
        gvm.tabledata.push(tblOject);
    }

    gvm.clearTable = function() {
        gvm.tabledata.removeAll();
    }
}

function getAllWorksheets() {
    worksheets = [];
    worksheetsid = [];
    $.getJSON('/api/worksheets/' + selectedcourseid, function(data) {
        $.each(data, function(i, item) {
            worksheets.push(item.Name);
            worksheetsid.push(item.id);
        });
    });
    return worksheets;
}

function getWorksheetid() {
    var i = 0;
    var worksheet = 0;
    worksheets.forEach(function(entry) {
        if (new String(entry).valueOf() == new String($('#worksheetComplete').val()).valueOf()) {
            worksheet = worksheetsid[i];
        }
        i+= 1;
    });
    return worksheet;
}

function addWorksheet(worksheetid) {
    console.log("toe te voegenworksheet " + worksheetid + " voor " + studid);
    $.ajax({
        url: "/api/worksheetstudentcouple/" + worksheetid + "/" + studid,
        type: "POST",
        data: {'worksheetid': worksheetid, 'studid': studid},
        success: function(data) {
            //callback(true);
        },
        error: function(data) {
            console.log('Failed to add new student');
            //callback(false);
        }
    });
}

function loadTablePage(pagenr)
{
    $.getJSON('/api/worksheets/page/' + pagenr, function(data){

        /* Clear current table page */
        viewModel.clearTable();

        // Load table data
        $.each(data.data, function(i, item) {
            viewModel.addTableData(item.id,  item.firstname, item.lastname, item.mail);
        });

        /* Let previous en next buttons work */
        if(data.prev == "none"){
            $('#pager-prev-btn').addClass('disabled');
        } else {
            $('#pager-prev-btn').removeClass('disabled');
            $('#pager-prev-btn a').click(function(){
                loadTablePage(data.prev);
            });
        }

        if(data.next == "none"){
            $('#pager-next-btn').addClass('disabled');
        } else {
            $('#pager-next-btn').removeClass('disabled');
            $('#pager-next-btn a').click(function(){
                loadTablePage(data.next);
            });
        }

        // Number of pager buttons
        var numItems = $('.pager-nr-btn').length;

        /* Calculate for the pager buttons */
        var lowPage = Math.floor(pagenr/numItems) + 1;

        $('.pager-nr-btn').each(function() {
            /* calculate current page number */
            var thispagenr = lowPage++;

            /* Add the page number */
            $(this).html('' + thispagenr + '');

            /* Add active class to current page */
            if(thispagenr == pagenr) {
                $(this).addClass('active');
            } else {
                $(this).removeClass('active');
            }

            /* Disable inactive classes and bind handlers to active classes */
            if(thispagenr > data.pagecount) {
                $(this).addClass('disabled');
            } else {
                /* Add click listener for button */
                $(this).click(function() {
                    loadTablePage(thispagenr);
                });
            }
        });
    });
}

function initPage() {
    $.getJSON('/api/currentuser', function(data) {
        viewModel.userId = data.id;
        viewModel.updateDropdowns();
    });

    $('#addGroupForm').hide();

    $('#addWorksheetBtn').click(function() {
        $("#addGroupForm").show();
        $('#worksheetComplete').autocomplete({ source: getAllWorksheets() });
    });

    $('#addNewWorksheetBtn').click(function() {
        //TODO controle of er effectief een lijst / student geselecteerd is.
        console.log("geselecteerd " + $("input:radio[name='studenten']:checked").val())
        //controleren of het voor 1 student is of voor alle studenten
        if (new String ($('#studentenradio').val()) == new String("student")) {
            console.log("Add student");
            addWorksheet(getWorksheetid());
        }
            else if (new String ($('#studentenradio').val()) == new String("studentlist"))//studentlist
        {
            console.log("Add studentengroep");
        }
        else {
        console.log("Niets geselecteerd");
        }
        //table opnieuw laden
        loadTablePage(1);

        //Indien gewenst toevoegformulier weer verbergen.
        $('#worksheetComplete').val("");
        $('#addGroupForm').hide();
    });
}<|endoftext|>


<commit_before>import { h, render } from 'preact';
import App from './components/App'

render(<App />, document.getElementById('app'));
<commit_msg>update app container location<commit_after>import { h, render } from 'preact';
import App from './containers/App'

render(<App />, document.getElementById('app'));
<|endoftext|>


<commit_before>/******************************************
* Category Task Modal View
*/
app.Views.ModalCategoryTaskView = app.Views.GenericModalView.extend({

	templateHTML : 'modals/modalCategoryTask',

	// The DOM events //
	events: function(){
		return _.defaults({
			'submit #formSaveCat'  : 'saveCat'
		},
			app.Views.GenericModalView.prototype.events
		);
	},

	/** View Initialization
	*/
	initialize : function() {

		this.modal = $(this.el);

		// Check if it's a create or an update //
		if(_.isUndefined(this.model)){
			this.model = new app.Models.CategoryTask();
		}

		this.render();
	},

	/** Display the view
	*/
	render : function() {
		var self = this;

		// Retrieve the template //
		$.get("templates/" + this.templateHTML + ".html", function(templateData){

			var template = _.template(templateData, {
				lang  : app.lang,
				cat   : self.model
			});

			self.modal.html(template);

			app.views.advancedSelectBoxCatParentView = new app.Views.AdvancedSelectBoxView({el: $("#catParentCat"), collection: app.Collections.CategoriesTasks.prototype })
			app.views.advancedSelectBoxCatParentView.render();

			app.views.advancedSelectBoxCatServices = new app.Views.AdvancedSelectBoxView({el: $("#catServices"), collection: app.Collections.ClaimersServices.prototype })
			app.views.advancedSelectBoxCatServices.render();

			self.modal.modal('show');
		});

		return this;
	},

	/** Delete the model pass in the view
	*/
	saveCat: function(e){
		e.preventDefault();

		var self = this;

		// Set the button in loading State //
		$(this.el).find("button[type=submit]").button('loading');

		// Set the properties of the model //
		this.model.setName(this.$('#catName').val(), true);
		this.model.setCode(this.$('#catCode').val(), true);
		this.model.setParentCat(app.views.advancedSelectBoxCatParentView.getSelectedItem(), true);
		this.model.setServices(app.views.advancedSelectBoxCatServices.getSelectedItems(), true);

		/*var params = {
			name: this.$('#catName').val(),
			code: this.$('#catCode').val()
		};*/

		this.model.save()
			.done(function(data) {
				self.modal.modal('hide');

				// Create mode //
				if(self.model.isNew()) {
					self.model.setId(data);
					self.model.fetch({silent: true, data : {fields : app.Collections.CategoriesTasks.prototype.fields} }).done(function(){
						app.views.categoriesTasksListView.collection.add(self.model);
					})
				// Update mode //
				} else {
					self.model.fetch({ data : {fields : self.model.fields} });
				}
			})
			.fail(function (e) {
				app.Helpers.Main.printError(e);
			})
			.always(function () {
				$(self.el).find("button[type=submit]").button('reset');
			});
	},

});<commit_msg>Une catégorie de tâche ne peu plus être efant d'elle même<commit_after>/******************************************
* Category Task Modal View
*/
app.Views.ModalCategoryTaskView = app.Views.GenericModalView.extend({

	templateHTML : 'modals/modalCategoryTask',

	// The DOM events //
	events: function(){
		return _.defaults({
			'submit #formSaveCat'  : 'saveCat'
		},
			app.Views.GenericModalView.prototype.events
		);
	},

	/** View Initialization
	*/
	initialize : function() {

		this.modal = $(this.el);

		// Check if it's a create or an update //
		if(_.isUndefined(this.model)){
			this.model = new app.Models.CategoryTask();
		}

		this.render();
	},

	/** Display the view
	*/
	render : function() {
		var self = this;

		// Retrieve the template //
		$.get("templates/" + this.templateHTML + ".html", function(templateData){

			var template = _.template(templateData, {
				lang  : app.lang,
				cat   : self.model
			});

			self.modal.html(template);

			app.views.advancedSelectBoxCatParentView = new app.Views.AdvancedSelectBoxView({el: $("#catParentCat"), collection: app.Collections.CategoriesTasks.prototype })
			// Condition to prevent a Cat to be parent if itself //
			if(!self.model.isNew()){
				app.views.advancedSelectBoxCatParentView.setSearchParam({ field : 'id', operator : '!=', value : self.model.getId() }, true);
			}
			app.views.advancedSelectBoxCatParentView.render();

			app.views.advancedSelectBoxCatServices = new app.Views.AdvancedSelectBoxView({el: $("#catServices"), collection: app.Collections.ClaimersServices.prototype })
			app.views.advancedSelectBoxCatServices.render();

			self.modal.modal('show');
		});

		return this;
	},

	/** Delete the model pass in the view
	*/
	saveCat: function(e){
		e.preventDefault();

		var self = this;

		// Set the button in loading State //
		$(this.el).find("button[type=submit]").button('loading');

		// Set the properties of the model //
		this.model.setName(this.$('#catName').val(), true);
		this.model.setCode(this.$('#catCode').val(), true);
		this.model.setParentCat(app.views.advancedSelectBoxCatParentView.getSelectedItem(), true);
		this.model.setServices(app.views.advancedSelectBoxCatServices.getSelectedItems(), true);

		this.model.save()
			.done(function(data) {
				self.modal.modal('hide');

				// Create mode //
				if(self.model.isNew()) {
					self.model.setId(data);
					self.model.fetch({silent: true, data : {fields : app.Collections.CategoriesTasks.prototype.fields} }).done(function(){
						app.views.categoriesTasksListView.collection.add(self.model);
					})
				// Update mode //
				} else {
					self.model.fetch({ data : {fields : self.model.fields} });
				}
			})
			.fail(function (e) {
				app.Helpers.Main.printError(e);
			})
			.always(function () {
				$(self.el).find("button[type=submit]").button('reset');
			});
	},

});<|endoftext|>


<commit_before>'use strict';

var yeoman = require('yeoman-generator'),
  util = require('util'),
  path = require('path'),
  chalk = require('chalk'),
  _ = require('lodash'),
  npmLatest = require('npm-latest'),
  bowerLatest = require('bower-latest');

var SandboxGenerator =  module.exports = function SandboxGenerator(args, options) {
  yeoman.generators.Base.apply(this, arguments);

  this.options = _.merge(this.options, {
    reqTimeout : 15000
  });
  _.merge(this.options, options);

  this.on('end', function () {
    this.installDependencies({ skipInstall: options['skip-install'] });
  });
};

util.inherits(SandboxGenerator, yeoman.generators.Base);

SandboxGenerator.prototype._stringifyPrettyJSON = function _stringifyPrettyJSON(obj) {
  return JSON.stringify(obj, null, 2);
};

// Welcome message
SandboxGenerator.prototype.welcome = function welcome() {
  if (!this.options['skip-welcome-message']) {
    this.log(this.yeoman);
    this.log(chalk.magenta('Welcome to the Sandbox generator.'));
  }
};

SandboxGenerator.prototype.promptUser = function promptUser() {
  var done = this.async();

  var prompts = [{
    name: 'appName',
    message: 'What is the name of your app?',
    default: path.basename(process.cwd())
  }, {
    type: 'checkbox',
    name: 'basicFeatures',
    message: 'What would you like to include?',
    choices: [{
      name: 'AngularJS',
      value: 'includeAngular',
      checked: false
    }, {
      name: 'Lo-dash',
      value: 'includeLodash',
      checked: false
    }, {
      name: 'SCSS',
      value: 'includeScss',
      checked: false
    }, {
      name: 'Gulpicon',
      value: 'includeGulpicon',
      checked: false
    }]
  }, {
    when: function (answers) {
      return answers.basicFeatures.indexOf('includeAngular') !== -1;
    },
    type: 'checkbox',
    name: 'angularFeatures',
    message: 'Which Angular features would you like to include?',
    choices: [{
      name: 'angular-resource.js',
      value: 'includeAngularResource',
      checked: false
    }, {
      name: 'angular-cookies.js',
      value: 'includeAngularCookies',
      checked: false
    }, {
      name: 'angular-sanitize.js',
      value: 'includeAngularSanitize',
      checked: false
    }, {
      name: 'angular-route.js',
      value: 'includeAngularRoute',
      checked: false
    }, {
      name: 'angular-ui-route.js',
      value: 'includeAngularUiRouter',
      checked: false
    }]
  }, {
    when: function (answers) {
      return answers.basicFeatures.indexOf('includeScss') !== -1;
    },
    type: 'checkbox',
    name: 'scssFeatures',
    message: 'Which SCSS features would you like to include?',
    choices: [{
      name: 'Inuit.css',
      value: 'includeInuitCss',
      checked: false
    },
      new yeoman.inquirer.Separator(),
    {
      name: 'Normalize.scss',
      value: 'includeNormalizeScss',
      checked: false
    }, {
      name: 'Csswizardry-grids',
      value: 'includeCsswizardryGrids',
      checked: false
    }]
  }];

  this.prompt(prompts, function (answers) {
    this.appName = this._.trim(answers.appName);
    this.slugName = this._.slugify(this.appName);
    this.camelName = this._.camelize(this.appName);

    var features = answers.basicFeatures.concat(answers.angularFeatures).concat(answers.scssFeatures);

    function hasFeature(feat) {
      return features.indexOf(feat) !== -1;
    }
    this.includeAngular = hasFeature('includeAngular');
    this.includeAngularResource = hasFeature('includeAngularResource');
    this.includeAngularCookies = hasFeature('includeAngularCookies');
    this.includeAngularSanitize = hasFeature('includeAngularSanitize');
    this.includeAngularRoute = hasFeature('includeAngularRoute');
    this.includeAngularUiRouter = hasFeature('includeAngularUiRouter');
    this.includeLodash = hasFeature('includeLodash');
    this.includeScss = hasFeature('includeScss');
    this.includeInuitCss = hasFeature('includeInuitCss');
    this.includeNormalizeScss = hasFeature('includeNormalizeScss');
    this.includeCsswizardryGrids = hasFeature('includeCsswizardryGrids');
    this.includeGulpicon = hasFeature('includeGulpicon');

    done();
  }.bind(this));
};

SandboxGenerator.prototype.app = function app() {
  this.mkdir('public');
  this.mkdir('public/scripts');
  this.mkdir('public/styles');

  this.template('_index.html', 'public/index.html');
  this.template('_app.js', 'public/scripts/app.js');

  if (this.includeScss) {
    this.mkdir('public/styles/css');
    this.mkdir('public/styles/scss');
    this.template('_main.scss', 'public/styles/scss/main.scss');
  } else {
    this.copy('_main.css', 'public/styles/main.css');
  }
};

SandboxGenerator.prototype.wireDep = function wireDep() {
  var scriptExcludes = [];
  if (this.includeAngular === true) {
    scriptExcludes.push(/angular\//);
  }
  if (this.includeLodash === true) {
    scriptExcludes.push(/lodash\//);
  }
  this.wiredepScriptExcludes = scriptExcludes.join(', ');

  var scssExcludes = [];
  if (this.includeInuitCss === true) {
    scssExcludes.push(/inuit.css\//);
  }
  if (this.includeNormalizeScss === true) {
    scssExcludes.push(/modularized-normalize-scss\//);
  }
  if (this.includeCsswizardryGrids === true) {
    scssExcludes.push(/csswizardry-grids\//);
  }
  this.wiredepScssExcludes = scssExcludes.join(', ');
};

SandboxGenerator.prototype.gulpfile = function gulpfile() {
  this.template('_gulpfile.js', 'gulpfile.js');
};

SandboxGenerator.prototype.jsHint = function jsHint() {
  this.template('jshintrc', '.jshintrc');
};

SandboxGenerator.prototype.jscsJson = function jscsJson() {
  this.copy('jscs.json', '.jscs.json');
};

SandboxGenerator.prototype.editorConfig = function editorConfig() {
  this.copy('editorconfig', '.editorconfig');
};

SandboxGenerator.prototype.git = function git() {
  this.copy('gitattributes', '.gitattributes');
  this.template('gitignore', '.gitignore');
};

SandboxGenerator.prototype.readme = function readme() {
  this.template('_README.md', 'README.md');
};

SandboxGenerator.prototype.gulpicon = function gulpicon() {
  if (this.includeGulpicon === true) {
    this.mkdir('public/images');
    this.mkdir('public/images/icons');
    this.mkdir('public/images/icons/src');
    this.mkdir('public/images/icons/templates');
    this.copy('_gulpicon-styles.hbs', 'public/images/icons/templates/gulpicon-styles.hbs');
    this.copy('_gulpicon-preview.hbs', 'public/images/icons/templates/gulpicon-preview.hbs');
    this.mkdir('public/images/icons/lib/');
    this.copy('_gulpicon-img-stats.js', 'public/images/icons/lib/img-stats.js');
    this.copy('_gulpicon-helper.js', 'public/images/icons/lib/gulpicon-helper.js');
    this.copy('_gulpicon-loader.js', 'public/images/icons/lib/gulpicon-loader.js');
    this.mkdir('public/images/icons/dest/');
    this.write('public/images/icons/dest/icons.data.svg.css', '');
    this.write('public/images/icons/dest/icons.data.png.css', '');
    this.write('public/images/icons/dest/icons.fallback.css', '');
  }
};

SandboxGenerator.prototype.packageJSON = function packageJSON() {
  var cb = this.async();

  // Generate package.json
  var _packageJSON = require(path.join(__dirname + '/templates/_package.json'));
  _packageJSON.name = this.slugName;

  var npmList = [];

  // Add dev-dependencies
  npmList.push('gulp');
  if (this.includeScss === true) {
    npmList.push('gulp-ruby-sass');
  }
  npmList.push('gulp-jshint');
  npmList.push('gulp-jscs');
  npmList.push('jshint-stylish');
  npmList.push('gulp-open');
  npmList.push('gulp-livereload');
  npmList.push('gulp-notify-growl');
  npmList.push('connect');
  npmList.push('serve-static');
  npmList.push('morgan');
  npmList.push('wiredep');
  if (this.includeAngular === true) {
    npmList.push('generator-angular');
    npmList.push('karma');
    npmList.push('karma-jasmine');
    npmList.push('karma-chrome-launcher');
    npmList.push('gulp-util');
    npmList.push('lodash');
  }
  if (this.includeGulpicon === true) {
    npmList.push('directory-encoder');
    npmList.push('gulp-svgmin');
    npmList.push('gulp-clean');
    npmList.push('svg-to-png');
    npmList.push('gulp-filter');
    npmList.push('gulp-rename');
    npmList.push('event-stream');
    npmList.push('xmldom');
    npmList.push('handlebars');
    npmList.push('lodash');
    npmList.push('event-stream');
    npmList.push('uglify-js');
  }

  var count = npmList.length;

  if (count === 0) {
    return cb();
  }

  var that = this;
  _.each(npmList, function (packageName) {
    npmLatest(packageName, {timeout: that.options.reqTimeout}, function (err, result) {
      var name = packageName;
      var version = '*';
      if (!err && result.name && result.version) {
        name = result.name;
        version = result.version;
      }
      _packageJSON.devDependencies[name] = version;
      if (!--count) {
        // Write to file
        this.write('package.json', this._stringifyPrettyJSON(_packageJSON));
        cb();
      }
    }.bind(this));
  }, this);
};

SandboxGenerator.prototype.bower = function bower() {
  var cb = this.async();

  // Generate bower.json
  var _bowerJSON = require(path.join(__dirname + '/templates/_bower.json'));
  _bowerJSON.name = this.slugName;

  if (this.includeAngular === true) {
    _bowerJSON.appPath = 'public';
    _bowerJSON.testPath = 'test/client/specs';
  }

  // Add dependencies
  var bowerDependencies = [];
  var bowerDevDependencies = [];

  if (this.includeAngular === true) {
    bowerDependencies.push('angular');
    bowerDevDependencies.push('angular-mocks');
    bowerDevDependencies.push('angular-scenario');
    if (this.includeAngularResource === true) {
      bowerDependencies.push('angular-resource');
    }
    if (this.includeAngularCookies === true) {
      bowerDependencies.push('angular-cookies');
    }
    if (this.includeAngularSanitize === true) {
      bowerDependencies.push('angular-sanitize');
    }
    if (this.includeAngularRoute === true) {
      bowerDependencies.push('angular-route');
    }
    if (this.includeAngularUiRouter === true) {
      bowerDependencies.push('angular-ui-router');
    }
  }
  if (this.includeLodash === true) {
    bowerDependencies.push('lodash');
  }
  if (this.includeNormalizeScss === true) {
    bowerDependencies.push('modularized-normalize-scss');
  }
  if (this.includeCsswizardryGrids === true) {
    bowerDependencies.push('csswizardry-grids');
  }
  if (this.includeInuitCss === true) {
    bowerDependencies.push('inuit.css');
  }

  var bowerList = bowerDependencies.concat(bowerDevDependencies);
  var count = bowerList.length;

  if (count === 0) {
    this.write('bower.json', this._stringifyPrettyJSON(_bowerJSON));
    this.copy('bowerrc', '.bowerrc');
    return cb();
  }

  var that = this;
  _.each(bowerList, function (packageName) {
    bowerLatest(packageName, {timeout: that.options.reqTimeout}, function (result) {
      var name = packageName;
      var version = '*';
      if (result && result.name && result.version) {
        name = result.name;
        version = result.version;
      }
      if (bowerDependencies.indexOf(packageName) !== -1) {
        _bowerJSON.dependencies[name] = version;
      } else {
        _bowerJSON.devDependencies[name] = version;
      }
      if (!--count) {
        // Write to file
        that.write('bower.json', that._stringifyPrettyJSON(_bowerJSON));
        that.copy('bowerrc', '.bowerrc');
        cb();
      }
    });
  });
};
<commit_msg>change package versions to match range<commit_after>'use strict';

var yeoman = require('yeoman-generator'),
  util = require('util'),
  path = require('path'),
  chalk = require('chalk'),
  _ = require('lodash'),
  npmLatest = require('npm-latest'),
  bowerLatest = require('bower-latest');

var SandboxGenerator =  module.exports = function SandboxGenerator(args, options) {
  yeoman.generators.Base.apply(this, arguments);

  this.options = _.merge(this.options, {
    reqTimeout : 15000
  });
  _.merge(this.options, options);

  this.on('end', function () {
    this.installDependencies({ skipInstall: options['skip-install'] });
  });
};

util.inherits(SandboxGenerator, yeoman.generators.Base);

SandboxGenerator.prototype._stringifyPrettyJSON = function _stringifyPrettyJSON(obj) {
  return JSON.stringify(obj, null, 2);
};

// Welcome message
SandboxGenerator.prototype.welcome = function welcome() {
  if (!this.options['skip-welcome-message']) {
    this.log(this.yeoman);
    this.log(chalk.magenta('Welcome to the Sandbox generator.'));
  }
};

SandboxGenerator.prototype.promptUser = function promptUser() {
  var done = this.async();

  var prompts = [{
    name: 'appName',
    message: 'What is the name of your app?',
    default: path.basename(process.cwd())
  }, {
    type: 'checkbox',
    name: 'basicFeatures',
    message: 'What would you like to include?',
    choices: [{
      name: 'AngularJS',
      value: 'includeAngular',
      checked: false
    }, {
      name: 'Lo-dash',
      value: 'includeLodash',
      checked: false
    }, {
      name: 'SCSS',
      value: 'includeScss',
      checked: false
    }, {
      name: 'Gulpicon',
      value: 'includeGulpicon',
      checked: false
    }]
  }, {
    when: function (answers) {
      return answers.basicFeatures.indexOf('includeAngular') !== -1;
    },
    type: 'checkbox',
    name: 'angularFeatures',
    message: 'Which Angular features would you like to include?',
    choices: [{
      name: 'angular-resource.js',
      value: 'includeAngularResource',
      checked: false
    }, {
      name: 'angular-cookies.js',
      value: 'includeAngularCookies',
      checked: false
    }, {
      name: 'angular-sanitize.js',
      value: 'includeAngularSanitize',
      checked: false
    }, {
      name: 'angular-route.js',
      value: 'includeAngularRoute',
      checked: false
    }, {
      name: 'angular-ui-route.js',
      value: 'includeAngularUiRouter',
      checked: false
    }]
  }, {
    when: function (answers) {
      return answers.basicFeatures.indexOf('includeScss') !== -1;
    },
    type: 'checkbox',
    name: 'scssFeatures',
    message: 'Which SCSS features would you like to include?',
    choices: [{
      name: 'Inuit.css',
      value: 'includeInuitCss',
      checked: false
    },
      new yeoman.inquirer.Separator(),
    {
      name: 'Normalize.scss',
      value: 'includeNormalizeScss',
      checked: false
    }, {
      name: 'Csswizardry-grids',
      value: 'includeCsswizardryGrids',
      checked: false
    }]
  }];

  this.prompt(prompts, function (answers) {
    this.appName = this._.trim(answers.appName);
    this.slugName = this._.slugify(this.appName);
    this.camelName = this._.camelize(this.appName);

    var features = answers.basicFeatures.concat(answers.angularFeatures).concat(answers.scssFeatures);

    function hasFeature(feat) {
      return features.indexOf(feat) !== -1;
    }
    this.includeAngular = hasFeature('includeAngular');
    this.includeAngularResource = hasFeature('includeAngularResource');
    this.includeAngularCookies = hasFeature('includeAngularCookies');
    this.includeAngularSanitize = hasFeature('includeAngularSanitize');
    this.includeAngularRoute = hasFeature('includeAngularRoute');
    this.includeAngularUiRouter = hasFeature('includeAngularUiRouter');
    this.includeLodash = hasFeature('includeLodash');
    this.includeScss = hasFeature('includeScss');
    this.includeInuitCss = hasFeature('includeInuitCss');
    this.includeNormalizeScss = hasFeature('includeNormalizeScss');
    this.includeCsswizardryGrids = hasFeature('includeCsswizardryGrids');
    this.includeGulpicon = hasFeature('includeGulpicon');

    done();
  }.bind(this));
};

SandboxGenerator.prototype.app = function app() {
  this.mkdir('public');
  this.mkdir('public/scripts');
  this.mkdir('public/styles');

  this.template('_index.html', 'public/index.html');
  this.template('_app.js', 'public/scripts/app.js');

  if (this.includeScss) {
    this.mkdir('public/styles/css');
    this.mkdir('public/styles/scss');
    this.template('_main.scss', 'public/styles/scss/main.scss');
  } else {
    this.copy('_main.css', 'public/styles/main.css');
  }
};

SandboxGenerator.prototype.wireDep = function wireDep() {
  var scriptExcludes = [];
  if (this.includeAngular === true) {
    scriptExcludes.push(/angular\//);
  }
  if (this.includeLodash === true) {
    scriptExcludes.push(/lodash\//);
  }
  this.wiredepScriptExcludes = scriptExcludes.join(', ');

  var scssExcludes = [];
  if (this.includeInuitCss === true) {
    scssExcludes.push(/inuit.css\//);
  }
  if (this.includeNormalizeScss === true) {
    scssExcludes.push(/modularized-normalize-scss\//);
  }
  if (this.includeCsswizardryGrids === true) {
    scssExcludes.push(/csswizardry-grids\//);
  }
  this.wiredepScssExcludes = scssExcludes.join(', ');
};

SandboxGenerator.prototype.gulpfile = function gulpfile() {
  this.template('_gulpfile.js', 'gulpfile.js');
};

SandboxGenerator.prototype.jsHint = function jsHint() {
  this.template('jshintrc', '.jshintrc');
};

SandboxGenerator.prototype.jscsJson = function jscsJson() {
  this.copy('jscs.json', '.jscs.json');
};

SandboxGenerator.prototype.editorConfig = function editorConfig() {
  this.copy('editorconfig', '.editorconfig');
};

SandboxGenerator.prototype.git = function git() {
  this.copy('gitattributes', '.gitattributes');
  this.template('gitignore', '.gitignore');
};

SandboxGenerator.prototype.readme = function readme() {
  this.template('_README.md', 'README.md');
};

SandboxGenerator.prototype.gulpicon = function gulpicon() {
  if (this.includeGulpicon === true) {
    this.mkdir('public/images');
    this.mkdir('public/images/icons');
    this.mkdir('public/images/icons/src');
    this.mkdir('public/images/icons/templates');
    this.copy('_gulpicon-styles.hbs', 'public/images/icons/templates/gulpicon-styles.hbs');
    this.copy('_gulpicon-preview.hbs', 'public/images/icons/templates/gulpicon-preview.hbs');
    this.mkdir('public/images/icons/lib/');
    this.copy('_gulpicon-img-stats.js', 'public/images/icons/lib/img-stats.js');
    this.copy('_gulpicon-helper.js', 'public/images/icons/lib/gulpicon-helper.js');
    this.copy('_gulpicon-loader.js', 'public/images/icons/lib/gulpicon-loader.js');
    this.mkdir('public/images/icons/dest/');
    this.write('public/images/icons/dest/icons.data.svg.css', '');
    this.write('public/images/icons/dest/icons.data.png.css', '');
    this.write('public/images/icons/dest/icons.fallback.css', '');
  }
};

SandboxGenerator.prototype.packageJSON = function packageJSON() {
  var cb = this.async();

  // Generate package.json
  var _packageJSON = require(path.join(__dirname + '/templates/_package.json'));
  _packageJSON.name = this.slugName;

  var npmList = [];

  // Add dev-dependencies
  npmList.push('gulp');
  if (this.includeScss === true) {
    npmList.push('gulp-ruby-sass');
  }
  npmList.push('gulp-jshint');
  npmList.push('gulp-jscs');
  npmList.push('jshint-stylish');
  npmList.push('gulp-open');
  npmList.push('gulp-livereload');
  npmList.push('gulp-notify-growl');
  npmList.push('connect');
  npmList.push('serve-static');
  npmList.push('morgan');
  npmList.push('wiredep');
  if (this.includeAngular === true) {
    npmList.push('generator-angular');
    npmList.push('karma');
    npmList.push('karma-jasmine');
    npmList.push('karma-chrome-launcher');
    npmList.push('gulp-util');
    npmList.push('lodash');
  }
  if (this.includeGulpicon === true) {
    npmList.push('directory-encoder');
    npmList.push('gulp-svgmin');
    npmList.push('gulp-clean');
    npmList.push('svg-to-png');
    npmList.push('gulp-filter');
    npmList.push('gulp-rename');
    npmList.push('event-stream');
    npmList.push('xmldom');
    npmList.push('handlebars');
    npmList.push('lodash');
    npmList.push('event-stream');
    npmList.push('uglify-js');
  }

  var count = npmList.length;

  if (count === 0) {
    return cb();
  }

  var that = this;
  _.each(npmList, function (packageName) {
    npmLatest(packageName, {timeout: that.options.reqTimeout}, function (err, result) {
      var name = packageName;
      var version = '*';
      if (!err && result.name && result.version) {
        name = result.name;
        version = '^' + result.version;
      }
      _packageJSON.devDependencies[name] = version;
      if (!--count) {
        // Write to file
        this.write('package.json', this._stringifyPrettyJSON(_packageJSON));
        cb();
      }
    }.bind(this));
  }, this);
};

SandboxGenerator.prototype.bower = function bower() {
  var cb = this.async();

  // Generate bower.json
  var _bowerJSON = require(path.join(__dirname + '/templates/_bower.json'));
  _bowerJSON.name = this.slugName;

  if (this.includeAngular === true) {
    _bowerJSON.appPath = 'public';
    _bowerJSON.testPath = 'test/client/specs';
  }

  // Add dependencies
  var bowerDependencies = [];
  var bowerDevDependencies = [];

  if (this.includeAngular === true) {
    bowerDependencies.push('angular');
    bowerDevDependencies.push('angular-mocks');
    bowerDevDependencies.push('angular-scenario');
    if (this.includeAngularResource === true) {
      bowerDependencies.push('angular-resource');
    }
    if (this.includeAngularCookies === true) {
      bowerDependencies.push('angular-cookies');
    }
    if (this.includeAngularSanitize === true) {
      bowerDependencies.push('angular-sanitize');
    }
    if (this.includeAngularRoute === true) {
      bowerDependencies.push('angular-route');
    }
    if (this.includeAngularUiRouter === true) {
      bowerDependencies.push('angular-ui-router');
    }
  }
  if (this.includeLodash === true) {
    bowerDependencies.push('lodash');
  }
  if (this.includeNormalizeScss === true) {
    bowerDependencies.push('modularized-normalize-scss');
  }
  if (this.includeCsswizardryGrids === true) {
    bowerDependencies.push('csswizardry-grids');
  }
  if (this.includeInuitCss === true) {
    bowerDependencies.push('inuit.css');
  }

  var bowerList = bowerDependencies.concat(bowerDevDependencies);
  var count = bowerList.length;

  if (count === 0) {
    this.write('bower.json', this._stringifyPrettyJSON(_bowerJSON));
    this.copy('bowerrc', '.bowerrc');
    return cb();
  }

  var that = this;
  _.each(bowerList, function (packageName) {
    bowerLatest(packageName, {timeout: that.options.reqTimeout}, function (result) {
      var name = packageName;
      var version = '*';
      if (result && result.name && result.version) {
        name = result.name;
        version = '^' + result.version;
      }
      if (bowerDependencies.indexOf(packageName) !== -1) {
        _bowerJSON.dependencies[name] = version;
      } else {
        _bowerJSON.devDependencies[name] = version;
      }
      if (!--count) {
        // Write to file
        that.write('bower.json', that._stringifyPrettyJSON(_bowerJSON));
        that.copy('bowerrc', '.bowerrc');
        cb();
      }
    });
  });
};
<|endoftext|>


<commit_before>import React from 'react';

import Actions from './CustomSocketsActions';

import ListItem from './CustomSocketsListItem';
import { colors as Colors } from 'material-ui/styles';
import { ColumnList, Lists, EmptyView } from '../../common/';

const Column = ColumnList.Column;

const CustomSocketsList = React.createClass({
  renderItem(item) {
    return (
      <ListItem
        key={`custom-socket-list-item-${item.name}`}
        item={item}
      />
    );
  },

  renderHeader() {
    return (
      <ColumnList.Header>
        <Column.ColumnHeader
          className="col-flex-1"
          primary={true}
          columnName="CHECK_ICON"
        >
          Socket Name
        </Column.ColumnHeader>
        <Column.ColumnHeader
          columnName="DESC"
          className="col-flex-3"
        >
          Description
        </Column.ColumnHeader>
        <Column.ColumnHeader
          className="col-xs-4"
        >
          Endpoints
        </Column.ColumnHeader>
      </ColumnList.Header>
    );
  },

  render() {
    const {
      items,
      isLoading,
      style,
      ...other
    } = this.props;

    if ((!items || !items.length) && !isLoading) {
      return (
        <EmptyView
          iconClassName="synicon-socket-custom-socket"
          buttonLabel="Add a Socket"
          iconColor={Colors.purple400}
          title="Syncano Sockets"
          urlLabel="Syncano Sockets"
          description="Use Syncano CLI to install a Socket from library"
          docsUrl="http://docs.syncano.io/docs"
          handleClick={Actions.showDialog}
        />
      );
    }

    return (
      <Lists.Container style={style}>
        {this.renderHeader()}
        <Lists.List
          {...other}
          isLoading={isLoading}
          items={items}
          key="custom-sockets-list"
          renderItem={this.renderItem}
        />
      </Lists.Container>
    );
  }
});

export default CustomSocketsList;
<commit_msg>[SYN5-318] Remove add button from My Sockets zero state<commit_after>import React from 'react';

import ListItem from './CustomSocketsListItem';
import { colors as Colors } from 'material-ui/styles';
import { ColumnList, Lists, EmptyView } from '../../common/';

const Column = ColumnList.Column;

const CustomSocketsList = React.createClass({
  renderItem(item) {
    return (
      <ListItem
        key={`custom-socket-list-item-${item.name}`}
        item={item}
      />
    );
  },

  renderHeader() {
    return (
      <ColumnList.Header>
        <Column.ColumnHeader
          className="col-flex-1"
          primary={true}
          columnName="CHECK_ICON"
        >
          Socket Name
        </Column.ColumnHeader>
        <Column.ColumnHeader
          columnName="DESC"
          className="col-flex-3"
        >
          Description
        </Column.ColumnHeader>
        <Column.ColumnHeader
          className="col-xs-4"
        >
          Endpoints
        </Column.ColumnHeader>
      </ColumnList.Header>
    );
  },

  render() {
    const {
      items,
      isLoading,
      style,
      ...other
    } = this.props;

    if ((!items || !items.length) && !isLoading) {
      return (
        <EmptyView
          iconClassName="synicon-socket-custom-socket"
          iconColor={Colors.purple400}
          title="Syncano Sockets"
          urlLabel="Syncano Sockets"
          description="Use Syncano CLI to install a Socket from library"
          docsUrl="http://docs.syncano.io/docs"
        />
      );
    }

    return (
      <Lists.Container style={style}>
        {this.renderHeader()}
        <Lists.List
          {...other}
          isLoading={isLoading}
          items={items}
          key="custom-sockets-list"
          renderItem={this.renderItem}
        />
      </Lists.Container>
    );
  }
});

export default CustomSocketsList;
<|endoftext|>


<commit_before>vgl.DataBuffers = function (initialSize) {
    if (!(this instanceof vgl.DataBuffers)) {
      return new vgl.DataBuffers(initialSize);
    }

    var data = {};

    var size;
    if (!initialSize)
        size = 256;
    else
        size = initialSize;

    var current = 0;

    var copyArray = function (dst, src, start, count) {
        if (!dst)
            console.log ('ack');
        if (!start)
            start = 0;
        if (!count)
            count = src.length;
        for (var i = 0; i < count; i ++) {
            dst[start + i] = src[i];
        }
    };

    var resize = function (min_expand) {
        var new_size = size;
        while (new_size < min_expand)
            new_size *= 2;
        size = new_size;
        for (var name in data) {
            var newArray = new Float32Array (new_size * data[name].len);
            var oldArray = data[name].array;
            copyArray (newArray, oldArray);
            data[name].array = newArray;
            data[name].dirty = true;
        }
    };

    this.create = function (name, len) {
        if (!len)
            throw "Length of buffer must be a positive integer";
        var array = new Float32Array (size * len);
        data[name] = {
            array: array,
            len: len,
            dirty: false
        };
    };

    this.alloc = function (num) {
        if ((current + num) >= size)
            resize (current + num);
        var start = current;
        current += num;
        return start;
    };

    this.get = function (name) {
        return data[name].array;
    };

    this.write = function (name, array, start, count) {
        copyArray (data[name].array, array, start * data[name].len, count * data[name].len);
        data[name].dirty = true;
    };

    this.repeat = function (name, elem, start, count) {
        for (var i = 0; i < count; i ++) {
            copyArray (data[name].array, elem,
                       (start + i) * data[name].len, data[name].len);
        }
        data[name].dirty = true;
    };

    this.count = function () {
        return current;
    };

    this.data = function (name) {
        return data[name].array;
    };
};
<commit_msg>Change how memory is allocated.<commit_after>vgl.DataBuffers = function (initialSize) {
    if (!(this instanceof vgl.DataBuffers)) {
      return new vgl.DataBuffers(initialSize);
    }

    var data = {};

    var size;
    if (!initialSize)
        size = 256;
    else
        size = initialSize;

    var current = 0;

    var copyArray = function (dst, src, start, count) {
        if (!dst)
            console.log ('ack');
        if (!start)
            start = 0;
        if (!count)
            count = src.length;
        for (var i = 0; i < count; i ++) {
            dst[start + i] = src[i];
        }
    };

    var resize = function (min_expand) {
        var new_size = size;
        /* If the array would increase substantially, don't just double its
         * size.  If the array has been increasing gradually, double it as the
         * expectation is that it will increase again. */
        if (new_size * 2 < min_expand) {
            new_size = min_expand;
        }
        while (new_size < min_expand)
            new_size *= 2;
        size = new_size;
        for (var name in data) {
            var newArray = new Float32Array (new_size * data[name].len);
            var oldArray = data[name].array;
            copyArray (newArray, oldArray);
            data[name].array = newArray;
            data[name].dirty = true;
        }
    };

    this.create = function (name, len) {
        if (!len)
            throw "Length of buffer must be a positive integer";
        var array = new Float32Array (size * len);
        data[name] = {
            array: array,
            len: len,
            dirty: false
        };
    };

    this.alloc = function (num) {
        if ((current + num) >= size)
            resize (current + num);
        var start = current;
        current += num;
        return start;
    };

    this.get = function (name) {
        return data[name].array;
    };

    this.write = function (name, array, start, count) {
        copyArray (data[name].array, array, start * data[name].len, count * data[name].len);
        data[name].dirty = true;
    };

    this.repeat = function (name, elem, start, count) {
        for (var i = 0; i < count; i ++) {
            copyArray (data[name].array, elem,
                       (start + i) * data[name].len, data[name].len);
        }
        data[name].dirty = true;
    };

    this.count = function () {
        return current;
    };

    this.data = function (name) {
        return data[name].array;
    };
};
<|endoftext|>


<commit_before>const camelCase = require('lodash.camelcase');
const chalk = require('chalk');
const Generator = require('yeoman-generator');
const humanizeUrl = require('humanize-url');
const kebabCase = require('lodash.kebabcase');

module.exports = class extends Generator {
  prompting() {
    return this.prompt([
      {
        name: 'moduleName',
        message: 'Module name:',
        default: this.appname.replace(/\s/g, '-'),
        store: true,
      },
      {
        name: 'description',
        message: 'Description:',
        default: 'as cute as bunny',
        store: true,
      },
      {
        name: 'global',
        message: 'Let user install as global:',
        type: 'confirm',
        default: false,
      },
      {
        name: 'name',
        message: "Author's name:",
        default: this.user.git.name(),
        store: true,
      },
      {
        name: 'email',
        message: "Author's email:",
        default: this.user.git.email(),
        store: true,
      },
      {
        name: 'githubUsername',
        message: 'GitHub username:',
        store: true,
      },
      {
        name: 'website',
        message: 'Website:',
        store: true,
      },
      {
        name: 'yarn',
        message: 'Use yarn to install dependencies:',
        type: 'confirm',
      },
    ]).then((props) => {
      const mv = (from, to) => {
        this.fs.move(this.destinationPath(from), this.destinationPath(to));
      };

      this.yarn = props.yarn;

      const tpl = {
        moduleName: kebabCase(props.moduleName).toLowerCase(),
        camelModule: camelCase(props.moduleName),
        description: props.description,
        global: props.global,
        name: props.name,
        email: props.email,
        githubUsername: props.githubUsername,
        website: humanizeUrl(props.website),
      };

      this.fs.copyTpl(
        [`${this.templatePath()}/**`],
        this.destinationPath(),
        tpl
      );

      mv('_package.json', 'package.json');
      mv('_all-contributorsrc', '.all-contributorsrc');
      mv('_babelrc', '.babelrc');
      mv('_editorconfig', '.editorconfig');
      mv('_eslintignore', '.eslintignore');
      mv('_eslintrc.json', '.eslintrc.json');
      mv('_flowconfig', '.flowconfig');
      mv('_gitattributes', '.gitattributes');
      mv('_github/issue_template.md', '.github/issue_template.md');
      mv(
        '_github/pull_request_template.md',
        '.github/pull_request_template.md'
      );
      mv('_gitignore', '.gitignore');
      mv('_npmrc', '.npmrc');
      mv('_travis.yml', '.travis.yml');
    });
  }
  git() {
    this.spawnCommandSync('git', ['init', '--quiet']);
  }
  install() {
    this.log(
      chalk.green(
        '\nAll important files have been generated to your directory.\n'
      )
    );

    this.installDependencies({
      bower: false,
      npm: !this.yarn,
      yarn: this.yarn,
    });
  }
  end() {
    this.log(`\nThanks for using${chalk.green(' generator-bunny')}!`);
  }
};
<commit_msg>feat: use yarn automatically if it’s already installed 🍻<commit_after>const camelCase = require('lodash.camelcase');
const chalk = require('chalk');
const Generator = require('yeoman-generator');
const humanizeUrl = require('humanize-url');
const kebabCase = require('lodash.kebabcase');
const spawn = require('child_process').spawn;

module.exports = class extends Generator {
  prompting() {
    return this.prompt([
      {
        name: 'moduleName',
        message: 'Module name:',
        default: this.appname.replace(/\s/g, '-'),
        store: true,
      },
      {
        name: 'description',
        message: 'Description:',
        default: 'as cute as bunny',
        store: true,
      },
      {
        name: 'global',
        message: 'Let user install as global:',
        type: 'confirm',
        default: false,
      },
      {
        name: 'name',
        message: "Author's name:",
        default: this.user.git.name(),
        store: true,
      },
      {
        name: 'email',
        message: "Author's email:",
        default: this.user.git.email(),
        store: true,
      },
      {
        name: 'githubUsername',
        message: 'GitHub username:',
        store: true,
      },
      {
        name: 'website',
        message: 'Website:',
        store: true,
      },
    ]).then((props) => {
      const mv = (from, to) => {
        this.fs.move(this.destinationPath(from), this.destinationPath(to));
      };

      const tpl = {
        moduleName: kebabCase(props.moduleName).toLowerCase(),
        camelModule: camelCase(props.moduleName),
        description: props.description,
        global: props.global,
        name: props.name,
        email: props.email,
        githubUsername: props.githubUsername,
        website: humanizeUrl(props.website),
      };

      this.fs.copyTpl(
        [`${this.templatePath()}/**`],
        this.destinationPath(),
        tpl
      );

      mv('_package.json', 'package.json');
      mv('_all-contributorsrc', '.all-contributorsrc');
      mv('_babelrc', '.babelrc');
      mv('_editorconfig', '.editorconfig');
      mv('_eslintignore', '.eslintignore');
      mv('_eslintrc.json', '.eslintrc.json');
      mv('_flowconfig', '.flowconfig');
      mv('_gitattributes', '.gitattributes');
      mv('_github/issue_template.md', '.github/issue_template.md');
      mv(
        '_github/pull_request_template.md',
        '.github/pull_request_template.md'
      );
      mv('_gitignore', '.gitignore');
      mv('_npmrc', '.npmrc');
      mv('_travis.yml', '.travis.yml');
    });
  }
  git() {
    this.spawnCommandSync('git', ['init', '--quiet']);
  }
  install() {
    this.log(
      chalk.green(
        '\nAll important files have been generated to your directory.\n'
      )
    );

    const useYarn = () => {
      try {
        spawn.sync('yarnpkg --version', { stdio: 'ignore' });
        return true;
      } catch (e) {
        return false;
      }
    };

    this.installDependencies({
      bower: false,
      npm: !useYarn(),
      yarn: useYarn(),
    });
  }
  end() {
    this.log(`\nThanks for using${chalk.green(' generator-bunny')}!`);
  }
};
<|endoftext|>


<commit_before>/* eslint-disable no-template-curly-in-string */

export default {
  name: 'article-toolbar',
  configure (config) {
    config.addToolPanel('toolbar', [
      {
        name: 'document-tools',
        type: 'group',
        style: 'minimal',
        items: [
          { type: 'command', name: 'undo' },
          { type: 'command', name: 'redo' },
          { type: 'command', name: 'save' }
        ]
      },
      {
        name: 'primary-annotations',
        type: 'group',
        style: 'minimal',
        items: [
          { type: 'command', name: 'toggle-bold', label: 'bold', icon: 'bold' },
          { type: 'command', name: 'toggle-italic', label: 'italic', icon: 'italic' },
          { type: 'command', name: 'create-external-link', label: 'link', icon: 'link' }
        ]
      },
      {
        name: 'insert',
        type: 'dropdown',
        style: 'descriptive',
        items: [
          { type: 'command', name: 'insert-figure', label: 'figure' },
          { type: 'command', name: 'insert-image', label: 'image' },
          { type: 'command', name: 'insert-table', label: 'table' },
          { type: 'command', name: 'insert-block-quote', label: 'block-quote' },
          { type: 'command', name: 'insert-block-formula', label: 'equation' },
          { type: 'command', name: 'insert-file', label: 'file' },
          { type: 'command', name: 'insert-footnote', label: 'footnote' },
          { type: 'command', name: 'insert-reference', label: 'reference' },
          { type: 'separator', label: 'inline' },
          { type: 'command', name: 'insert-inline-formula', label: 'math' },
          { type: 'command', name: 'insert-inline-graphic', label: 'inline-graphic' },
          { type: 'command', name: 'create-external-link', label: 'link', icon: 'link' },
          { type: 'command', name: 'insert-xref-bibr', label: 'citation' },
          { type: 'command', name: 'insert-xref-figure', label: 'figure-reference' },
          { type: 'command', name: 'insert-xref-table', label: 'table-reference' },
          { type: 'command', name: 'insert-xref-footnote', label: 'footnote-reference' },
          { type: 'command', name: 'insert-xref-formula', label: 'equation-reference' },
          { type: 'command', name: 'insert-xref-file', label: 'file-reference' },
          { type: 'separator', label: 'metadata' },
          { type: 'command', name: 'insert-author', label: 'author' },
          { type: 'command', name: 'insert-editor', label: 'editor' },
          { type: 'command', name: 'insert-group', label: 'group' },
          { type: 'command', name: 'insert-organisation', label: 'affiliation' },
          { type: 'command', name: 'insert-award', label: 'award' },
          { type: 'command', name: 'insert-keyword', label: 'keyword' },
          { type: 'command', name: 'insert-subject', label: 'subject' }
        ]
      },
      // TODO: not sure yet. This could also be seen as a contextual thing
      {
        name: 'format',
        type: 'dropdown',
        style: 'descriptive',
        items: [
          { type: 'command', name: 'toggle-bold', label: 'bold' },
          { type: 'command', name: 'toggle-italic', label: 'italic' },
          { type: 'command', name: 'toggle-subscript', label: 'subscript' },
          { type: 'command', name: 'toggle-superscript', label: 'superscript' },
          { type: 'command', name: 'toggle-monospace', label: 'monospace' },
          { type: 'command', name: 'toggle-small-caps', label: 'small-caps' },
          { type: 'command', name: 'toggle-underline', label: 'underline' },
          { type: 'command', name: 'toggle-overline', label: 'overline' },
          { type: 'command', name: 'toggle-strike-through', label: 'strike-through' }
        ]
      },
      // Contextual stuff
      {
        name: 'text-types',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        displayActiveCommand: true,
        items: [
          { type: 'command-group', name: 'text-types' }
        ]
      },
      // TODO: we do not have a good concept for contextual tools
      // we considered to have a toolgroup which renders the context as a label
      // As we do not have such a thing, the closest we can get there
      // are drop-down menues which are visible only when enabled
      {
        name: 'table-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'table' },
          { type: 'command-group', name: 'table-insert' },
          { type: 'command-group', name: 'table-delete' }
        ]
      },
      {
        name: 'file-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'file' }
        ]
      },
      {
        name: 'figure-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'figure-panel' }
        ]
      },
      {
        name: 'footnote-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'footnote' }
        ]
      },
      {
        name: 'collection-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'collection' }
        ]
      },
      {
        name: 'list-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'list' }
        ]
      },
      {
        name: 'custom-field-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'custom-metadata-fields' }
        ]
      },
      {
        name: 'mode',
        type: 'dropdown',
        style: 'full',
        hideDisabled: true,
        items: [
          { type: 'command', name: 'open-manuscript', label: 'manuscript' },
          { type: 'command', name: 'open-metadata', label: 'metadata' }
        ]
      }
    ])

    // Icons
    config.addIcon('bold', { 'fontawesome': 'fa-bold' })
    config.addIcon('italic', { 'fontawesome': 'fa-italic' })
    config.addIcon('link', { 'fontawesome': 'fa-link' })

    // Format tools labels
    config.addLabel('format', 'Format')
    config.addLabel('bold', 'Bold')
    config.addLabel('italic', 'Italic')
    config.addLabel('link', 'Link')
    config.addLabel('subscript', 'Subscript')
    config.addLabel('superscript', 'Superscript')
    config.addLabel('monospace', 'Monospace')
    // List tools labels
    config.addLabel('list-tools', 'List')
    config.addLabel('toggle-unordered-list', {
      en: 'Bulleted list',
      de: 'Liste'
    })
    config.addLabel('toggle-ordered-list', {
      en: 'Numbered list',
      de: 'Aufzählung'
    })
    config.addLabel('indent-list', {
      en: 'Increase indentation',
      de: 'Einrückung vergrößern'
    })
    config.addLabel('dedent-list', {
      en: 'Decrease indentation',
      de: 'Einrückung verringern'
    })
    // Insert tools labels
    config.addLabel('insert', 'Insert')
    config.addLabel('figure', 'Figure')
    config.addLabel('table', 'Table')
    config.addLabel('block-quote', 'Block Quote')
    config.addLabel('equation', 'Equation')
    config.addLabel('file', 'File')
    config.addLabel('footnote', 'Footnote')
    config.addLabel('inline', 'Inline')
    config.addLabel('math', 'Math')
    config.addLabel('inline-graphic', 'Inline Graphic')
    config.addLabel('citation', 'Citation')
    config.addLabel('figure-reference', 'Figure Reference')
    config.addLabel('table-reference', 'Table Reference')
    config.addLabel('footnote-reference', 'Footnote Reference')
    config.addLabel('equation-reference', 'Equation Reference')
    config.addLabel('file-reference', 'File Reference')
    config.addLabel('metadata', 'Metadata')
    config.addLabel('reference', 'Reference')
    config.addLabel('author', 'Author')
    config.addLabel('editor', 'Editor')
    config.addLabel('group', 'Group')
    config.addLabel('affiliation', 'Affiliation')
    config.addLabel('award', 'Award')
    config.addLabel('keyword', 'Keyword')
    config.addLabel('subject', 'Subject')
    // Table tools labels
    config.addLabel('table-tools', 'Table')
    config.addLabel('insert-rows-above', {
      en: 'Insert ${nrows} rows above'
    })
    config.addLabel('insert-rows-below', {
      en: 'Insert ${nrows} rows below'
    })
    config.addLabel('insert-columns-left', {
      en: 'Insert ${ncols} columns left'
    })
    config.addLabel('insert-columns-right', {
      en: 'Insert ${ncols} columns right'
    })
    config.addLabel('delete-rows', {
      en: 'Delete ${nrows} rows'
    })
    config.addLabel('delete-columns', {
      en: 'Delete ${ncols} columns'
    })
    config.addLabel('toggle-cell-heading', {
      en: 'Cell heading'
    })
    config.addLabel('toggle-cell-merge', {
      en: 'Merge cell'
    })
    // File tools
    config.addLabel('file-tools', 'File')
    config.addLabel('replace-file', 'Replace File')
    // Figure tools
    config.addLabel('figure-tools', 'Figure')
    config.addLabel('add-figure-panel', 'Add Sub-Figure')
    config.addLabel('replace-figure-panel-image', 'Replace Sub-Figure Image')
    config.addLabel('remove-figure-panel', 'Remove Sub-Figure')
    config.addLabel('move-up-figure-panel', 'Move Up Sub-Figure')
    config.addLabel('move-down-figure-panel', 'Move Down Sub-Figure')
    // Footnote tools
    config.addLabel('footnote-tools', 'Footnote')
    config.addLabel('remove-footnote', 'Remove Footnote')
    // Collection tools
    config.addLabel('collection-tools', 'Collection')
    config.addLabel('move-up-col-item', 'Move Item Up')
    config.addLabel('move-down-col-item', 'Move Item Down')
    config.addLabel('remove-col-item', 'Remove Item')
    // Custom field tools
    config.addLabel('custom-field-tools', 'Metadata')
    config.addLabel('add-custom-metadata-field', 'Add Custom Field')
    // Mode
    config.addLabel('manuscript', 'Manuscript')
  }
}
<commit_msg>Add labels for custom field tools.<commit_after>/* eslint-disable no-template-curly-in-string */

export default {
  name: 'article-toolbar',
  configure (config) {
    config.addToolPanel('toolbar', [
      {
        name: 'document-tools',
        type: 'group',
        style: 'minimal',
        items: [
          { type: 'command', name: 'undo' },
          { type: 'command', name: 'redo' },
          { type: 'command', name: 'save' }
        ]
      },
      {
        name: 'primary-annotations',
        type: 'group',
        style: 'minimal',
        items: [
          { type: 'command', name: 'toggle-bold', label: 'bold', icon: 'bold' },
          { type: 'command', name: 'toggle-italic', label: 'italic', icon: 'italic' },
          { type: 'command', name: 'create-external-link', label: 'link', icon: 'link' }
        ]
      },
      {
        name: 'insert',
        type: 'dropdown',
        style: 'descriptive',
        items: [
          { type: 'command', name: 'insert-figure', label: 'figure' },
          { type: 'command', name: 'insert-image', label: 'image' },
          { type: 'command', name: 'insert-table', label: 'table' },
          { type: 'command', name: 'insert-block-quote', label: 'block-quote' },
          { type: 'command', name: 'insert-block-formula', label: 'equation' },
          { type: 'command', name: 'insert-file', label: 'file' },
          { type: 'command', name: 'insert-footnote', label: 'footnote' },
          { type: 'command', name: 'insert-reference', label: 'reference' },
          { type: 'separator', label: 'inline' },
          { type: 'command', name: 'insert-inline-formula', label: 'math' },
          { type: 'command', name: 'insert-inline-graphic', label: 'inline-graphic' },
          { type: 'command', name: 'create-external-link', label: 'link', icon: 'link' },
          { type: 'command', name: 'insert-xref-bibr', label: 'citation' },
          { type: 'command', name: 'insert-xref-figure', label: 'figure-reference' },
          { type: 'command', name: 'insert-xref-table', label: 'table-reference' },
          { type: 'command', name: 'insert-xref-footnote', label: 'footnote-reference' },
          { type: 'command', name: 'insert-xref-formula', label: 'equation-reference' },
          { type: 'command', name: 'insert-xref-file', label: 'file-reference' },
          { type: 'separator', label: 'metadata' },
          { type: 'command', name: 'insert-author', label: 'author' },
          { type: 'command', name: 'insert-editor', label: 'editor' },
          { type: 'command', name: 'insert-group', label: 'group' },
          { type: 'command', name: 'insert-organisation', label: 'affiliation' },
          { type: 'command', name: 'insert-award', label: 'award' },
          { type: 'command', name: 'insert-keyword', label: 'keyword' },
          { type: 'command', name: 'insert-subject', label: 'subject' }
        ]
      },
      // TODO: not sure yet. This could also be seen as a contextual thing
      {
        name: 'format',
        type: 'dropdown',
        style: 'descriptive',
        items: [
          { type: 'command', name: 'toggle-bold', label: 'bold' },
          { type: 'command', name: 'toggle-italic', label: 'italic' },
          { type: 'command', name: 'toggle-subscript', label: 'subscript' },
          { type: 'command', name: 'toggle-superscript', label: 'superscript' },
          { type: 'command', name: 'toggle-monospace', label: 'monospace' },
          { type: 'command', name: 'toggle-small-caps', label: 'small-caps' },
          { type: 'command', name: 'toggle-underline', label: 'underline' },
          { type: 'command', name: 'toggle-overline', label: 'overline' },
          { type: 'command', name: 'toggle-strike-through', label: 'strike-through' }
        ]
      },
      // Contextual stuff
      {
        name: 'text-types',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        displayActiveCommand: true,
        items: [
          { type: 'command-group', name: 'text-types' }
        ]
      },
      // TODO: we do not have a good concept for contextual tools
      // we considered to have a toolgroup which renders the context as a label
      // As we do not have such a thing, the closest we can get there
      // are drop-down menues which are visible only when enabled
      {
        name: 'table-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'table' },
          { type: 'command-group', name: 'table-insert' },
          { type: 'command-group', name: 'table-delete' }
        ]
      },
      {
        name: 'file-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'file' }
        ]
      },
      {
        name: 'figure-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'figure-panel' }
        ]
      },
      {
        name: 'footnote-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'footnote' }
        ]
      },
      {
        name: 'collection-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'collection' }
        ]
      },
      {
        name: 'list-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'list' }
        ]
      },
      {
        name: 'custom-field-tools',
        type: 'dropdown',
        style: 'descriptive',
        hideDisabled: true,
        items: [
          { type: 'command-group', name: 'custom-metadata-fields' }
        ]
      },
      {
        name: 'mode',
        type: 'dropdown',
        style: 'full',
        hideDisabled: true,
        items: [
          { type: 'command', name: 'open-manuscript', label: 'manuscript' },
          { type: 'command', name: 'open-metadata', label: 'metadata' }
        ]
      }
    ])

    // Icons
    config.addIcon('bold', { 'fontawesome': 'fa-bold' })
    config.addIcon('italic', { 'fontawesome': 'fa-italic' })
    config.addIcon('link', { 'fontawesome': 'fa-link' })

    // Format tools labels
    config.addLabel('format', 'Format')
    config.addLabel('bold', 'Bold')
    config.addLabel('italic', 'Italic')
    config.addLabel('link', 'Link')
    config.addLabel('subscript', 'Subscript')
    config.addLabel('superscript', 'Superscript')
    config.addLabel('monospace', 'Monospace')
    // List tools labels
    config.addLabel('list-tools', 'List')
    config.addLabel('toggle-unordered-list', {
      en: 'Bulleted list',
      de: 'Liste'
    })
    config.addLabel('toggle-ordered-list', {
      en: 'Numbered list',
      de: 'Aufzählung'
    })
    config.addLabel('indent-list', {
      en: 'Increase indentation',
      de: 'Einrückung vergrößern'
    })
    config.addLabel('dedent-list', {
      en: 'Decrease indentation',
      de: 'Einrückung verringern'
    })
    // Insert tools labels
    config.addLabel('insert', 'Insert')
    config.addLabel('figure', 'Figure')
    config.addLabel('table', 'Table')
    config.addLabel('block-quote', 'Block Quote')
    config.addLabel('equation', 'Equation')
    config.addLabel('file', 'File')
    config.addLabel('footnote', 'Footnote')
    config.addLabel('inline', 'Inline')
    config.addLabel('math', 'Math')
    config.addLabel('inline-graphic', 'Inline Graphic')
    config.addLabel('citation', 'Citation')
    config.addLabel('figure-reference', 'Figure Reference')
    config.addLabel('table-reference', 'Table Reference')
    config.addLabel('footnote-reference', 'Footnote Reference')
    config.addLabel('equation-reference', 'Equation Reference')
    config.addLabel('file-reference', 'File Reference')
    config.addLabel('metadata', 'Metadata')
    config.addLabel('reference', 'Reference')
    config.addLabel('author', 'Author')
    config.addLabel('editor', 'Editor')
    config.addLabel('group', 'Group')
    config.addLabel('affiliation', 'Affiliation')
    config.addLabel('award', 'Award')
    config.addLabel('keyword', 'Keyword')
    config.addLabel('subject', 'Subject')
    // Table tools labels
    config.addLabel('table-tools', 'Table')
    config.addLabel('insert-rows-above', {
      en: 'Insert ${nrows} rows above'
    })
    config.addLabel('insert-rows-below', {
      en: 'Insert ${nrows} rows below'
    })
    config.addLabel('insert-columns-left', {
      en: 'Insert ${ncols} columns left'
    })
    config.addLabel('insert-columns-right', {
      en: 'Insert ${ncols} columns right'
    })
    config.addLabel('delete-rows', {
      en: 'Delete ${nrows} rows'
    })
    config.addLabel('delete-columns', {
      en: 'Delete ${ncols} columns'
    })
    config.addLabel('toggle-cell-heading', {
      en: 'Cell heading'
    })
    config.addLabel('toggle-cell-merge', {
      en: 'Merge cell'
    })
    // File tools
    config.addLabel('file-tools', 'File')
    config.addLabel('replace-file', 'Replace File')
    // Figure tools
    config.addLabel('figure-tools', 'Figure')
    config.addLabel('add-figure-panel', 'Add Sub-Figure')
    config.addLabel('replace-figure-panel-image', 'Replace Sub-Figure Image')
    config.addLabel('remove-figure-panel', 'Remove Sub-Figure')
    config.addLabel('move-up-figure-panel', 'Move Up Sub-Figure')
    config.addLabel('move-down-figure-panel', 'Move Down Sub-Figure')
    // Footnote tools
    config.addLabel('footnote-tools', 'Footnote')
    config.addLabel('remove-footnote', 'Remove Footnote')
    // Collection tools
    config.addLabel('collection-tools', 'Collection')
    config.addLabel('move-up-col-item', 'Move Item Up')
    config.addLabel('move-down-col-item', 'Move Item Down')
    config.addLabel('remove-col-item', 'Remove Item')
    // Custom field tools
    config.addLabel('custom-field-tools', 'Metadata')
    config.addLabel('add-custom-metadata-field', 'Add Custom Field')
    config.addLabel('move-down-custom-metadata-field', 'Move Down Custom Field')
    config.addLabel('move-up-custom-metadata-field', 'Move Up Custom Field')
    config.addLabel('remove-custom-metadata-field', 'Remove Custom Field')
    // Mode
    config.addLabel('manuscript', 'Manuscript')
  }
}
<|endoftext|>