<commit_before>/*!
 * Copyright 2014 Digital Services, University of Cambridge Licensed
 * under the Educational Community License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 *     http://opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

define(['gh.core', 'gh.admin-constants', 'gh.api.orgunit', 'gh.api.series', 'gh.api.util'], function(gh, adminConstants, orgunitAPI, seriesAPI, utilAPI) {

    /**
     * Create a new series
     *
     * @private
     */
    var createNewSeries = function() {

        // Get the AppId
        var appId = require('gh.core').data.me.AppId;
        // Get the displayName
        var displayName = $('#gh-series-name').val();
        // Get the ID of the group that this new series belongs to
        var groupId = $(this).find('button[type="submit"]').data('groupid');
        // Get the ID of the parent that this new series will belong to
        var parentId = $(this).find('button[type="submit"]').data('parentid');
        // Get the ID of the part
        var partId = $(this).find('button[type="submit"]').data('partid');

        // Create a new series
        seriesAPI.createSeries(appId, displayName, null, groupId, function(err, data) {
            if (err) {
                return utilAPI.notification('Series not created.', 'The series could not be successfully created.', 'error');
            }

            // Link the created series to the module
            orgunitAPI.addOrgUnitSeries(parentId, data.id, function(err, data) {
                if (err) {
                    return utilAPI.notification('Series not created.', 'The series could not be successfully created.', 'error');
                }
                utilAPI.notification('Series created.', 'The series was successfully created.', 'success');

                // Refresh the listview
                $(document).trigger('gh.listview.refresh', {
                    'partId': partId
                });
            });
        });

        return false;
    };<commit_msg>Open a new series in batch edit mode after creating it<commit_after>/*!
 * Copyright 2014 Digital Services, University of Cambridge Licensed
 * under the Educational Community License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 *     http://opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

define(['gh.core', 'gh.admin-constants', 'gh.api.orgunit', 'gh.api.series', 'gh.api.util'], function(gh, adminConstants, orgunitAPI, seriesAPI, utilAPI) {

    /**
     * Create a new series
     *
     * @private
     */
    var createNewSeries = function() {

        // Get the AppId
        var appId = require('gh.core').data.me.AppId;
        // Get the displayName
        var displayName = $('#gh-series-name').val();
        // Get the ID of the group that this new series belongs to
        var groupId = $(this).find('button[type="submit"]').data('groupid');
        // Get the ID of the parent that this new series will belong to
        var parentId = $(this).find('button[type="submit"]').data('parentid');
        // Get the ID of the part
        var partId = $(this).find('button[type="submit"]').data('partid');

        // Create a new series
        seriesAPI.createSeries(appId, displayName, null, groupId, function(err, series) {
            if (err) {
                return utilAPI.notification('Series not created.', 'The series could not be successfully created.', 'error');
            }

            // Link the created series to the module
            orgunitAPI.addOrgUnitSeries(parentId, series.id, function(err) {
                if (err) {
                    return utilAPI.notification('Series not created.', 'The series could not be successfully created.', 'error');
                }
                utilAPI.notification('Series created.', 'The series was successfully created.', 'success');

                // Create a new state object that will take care of opening the new series for us
                var state = $.bbq.getState();
                state.module = parentId;
                state.series = series.id;
                $.bbq.pushState(state);
            });
        });

        return false;
    };
{'fraction_non_alphanumeric': 0.11518324607329843, 'fraction_numerical': 0.003221908981071285, 'mean_word_length': 2.372029871011541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '660134', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1233, 'n_words': 471}