<commit_before>/** OnboardingProgress view model.
    It tracks the onboarding information and methods
    to update views to that state
**/
var Model = require('../models/Model');
var ko = require('knockout');

/**
 * Definition of steps, in strict order, with settings from available:
 * - serviceProfessionalOnly:boolean Whether is display to professional users only
 * - jobTitleSpecific:boolean Whether the step needs a jobTitleID in order to work,
 * and accepts that as the first URL segment
 */
var STEPS = {
    welcome: {
        userFlags: ['isClient', 'isServiceProfessional']
    },
    publicContactInfo: {
        userFlags: ['isClient', 'isServiceProfessional']
    },
    addJobTitle: {
        userFlags: ['isServiceProfessional']
    },
    serviceAddresses: {
        userFlags: ['isServiceProfessional'],
        jobTitleSpecific: true
    }
};
var PROFESSIONAL_FINISH_STEP = 'listingEditor';
var CLIENT_FINISH_STEP = 'home';

function getUserSteps(user) {
    return Object.keys(STEPS)
    .filter(function(stepName) {
        const step = STEPS[stepName];
        return !!step.userFlags.some((flag) => user[flag]());
    });
}

function OnboardingProgress(values) {
    var stepNumberFinished = -1;

    Model(this);

    this.model.defProperties({
        isServiceProfessional: false,
        stepNumber: stepNumberFinished,
        // Let's set a job title to pass in to jobTitleSpecific steps as URL segment
        selectedJobTitleID: null
    }, values);

    this.stepNames = ko.pureComputed(function() {
        return getUserSteps(this);
    }, this);
    /**
     * Gives the name of the step (activity) that should be navigated after finishing
     * the onboarding.
     * @member {KnockoutComputed<string>}
     */
    this.stepAfterFinish = ko.pureComputed(function() {
        return this.isServiceProfessional() ? PROFESSIONAL_FINISH_STEP : CLIENT_FINISH_STEP;
    }, this);

    this.totalSteps = ko.pureComputed(function() {
        // 'Zero' step is a welcome, not accounted:
        return this.stepNames().length - 1;
    }, this);
<commit_msg>Updated onboarding with 'organization' user flag specifics #820<commit_after>/** OnboardingProgress view model.
    It tracks the onboarding information and methods
    to update views to that state
**/
var Model = require('../models/Model');
var ko = require('knockout');

/**
 * Definition of steps, in strict order, with settings from available:
 * - serviceProfessionalOnly:boolean Whether is display to professional users only
 * - jobTitleSpecific:boolean Whether the step needs a jobTitleID in order to work,
 * and accepts that as the first URL segment
 */
var STEPS = {
    welcome: {
        userFlags: ['isClient', 'isServiceProfessional']
    },
    publicContactInfo: {
        userFlags: ['isClient', 'isServiceProfessional']
    },
    organizationInfo: {
        userFlags: ['isOrganization']
    },
    addJobTitle: {
        userFlags: ['isServiceProfessional']
    },
    serviceAddresses: {
        userFlags: ['isServiceProfessional'],
        jobTitleSpecific: true
    }
};
var PROFESSIONAL_FINISH_STEP = 'listingEditor';
var CLIENT_FINISH_STEP = 'home';
var ORGANIZATION_FINISH_STEP = 'posting';

function getUserSteps(user) {
    return Object.keys(STEPS)
    .filter(function(stepName) {
        const step = STEPS[stepName];
        return !!step.userFlags.some((flag) => user[flag]());
    });
}

function OnboardingProgress(values) {
    var stepNumberFinished = -1;

    Model(this);

    this.model.defProperties({
        isServiceProfessional: false,
        stepNumber: stepNumberFinished,
        // Let's set a job title to pass in to jobTitleSpecific steps as URL segment
        selectedJobTitleID: null
    }, values);

    this.stepNames = ko.pureComputed(function() {
        return getUserSteps(this);
    }, this);
    /**
     * Gives the name of the step (activity) that should be navigated after finishing
     * the onboarding.
     * @member {KnockoutComputed<string>}
     */
    this.stepAfterFinish = ko.pureComputed(function() {
        return this.isOrganization() ?
            ORGANIZATION_FINISH_STEP :
            this.isServiceProfessional() ?
            PROFESSIONAL_FINISH_STEP :
            CLIENT_FINISH_STEP;
    }, this);

    this.totalSteps = ko.pureComputed(function() {
        // 'Zero' step is a welcome, not accounted:
        return this.stepNames().length - 1;
    }, this);

{'fraction_non_alphanumeric': 0.10703019378098243, 'fraction_numerical': 0.0015772870662460567, 'mean_word_length': 3.0874769797421733, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1361281', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1248, 'n_words': 345}