<commit_before>'use strict';

const EDITOR_MODE_CREATE = 1;
const EDITOR_MODE_EDIT   = 2;

const ADD_NEW_FIELD_BUTTON_ROW = 'add_new_field_button';

const DELETABLE_ROW = 'deletable_row';

function EntityEditor(entity_wall) {
    this.__init__(entity_wall);
}

EntityEditor.prototype = {

    __init__: function(entity_wall_manager) {
        this.entity_wall_manager = entity_wall_manager;
        this.base_wall = this.entity_wall_manager.base_wall;
        this.world = this.base_wall.world;
        this.entity_wall = this.entity_wall_manager.entity_wall;

        this.current_mode = null;
    },

    entity_name_changed: function() {
        if (is_defined(this.current_mode)) {
            if (this.current_mode === EDITOR_MODE_EDIT) {
                this.wall_title.update_text('Editing : ' + this.entity_name_input.get_text());
            }
        }
    },

    create_or_save_changes_button_pressed: function() {
        if (this.current_mode === EDITOR_MODE_CREATE) {
            this._entity_created();
        } else {
            this._modify_entity();
        }
    },

    cancel_or_delete_button_pressed: function() {
        if (this.current_mode === EDITOR_MODE_CREATE) {
            this.wall_entity_editor.force_hide_self_and_all_child_attachments_recursively();
        } else {
            this.entity_wall_manager.delete_entity(this.entity_being_edited);
        }
    },

    delete_entity_field: function(field_name) {
        if (field_name === ENTITY_PROPERTY_START_DATE_TIME || field_name === ENTITY_PROPERTY_END_DATE_TIME) {
            this.date_selector.wall_date_selector.detach_from_parent();
            this.time_selector.wall_time_selector.detach_from_parent();
        } else if (field_name === ENTITY_PROPERTY_COMPLETED) {
            this.completed_check_mark.detach_from_parent();
        }
        this.wall_entity_editor.delete_row_by_name(field_name);

        if (this.current_mode === EDITOR_MODE_EDIT) {
            this.entity_being_edited.delete_property(field_name);
        }

        this.base_wall.refresh_position_and_look_at();
    },

    create: function(edit_mode) {
        if (!is_defined(this.date_selector)) {
            // Both creating a new entity and editing an existing entity will potentially need to utilize the date selector.
            this.date_selector = new DateSelector(this.world, this.date_selected.bind(this));
        }
        if (!is_defined(this.time_selector)) {
            // Both creating a new entity and editing an existing entity will potentially need to utilize the time selector.
            this.time_selector = new TimeSelector(this.world, this.time_selected.bind(this));
        }
        // Checkmark used in the completed field.
        if (!is_defined(this.completed_check_mark)) {
            this.completed_check_mark = new Floating2DText(16, ICON_CHECKMARK, TYPE_ICON, this.world);
            this.completed_check_mark.set_attachment_depth_offset(2);
            this.completed_check_mark.set_attachment_horizontal_offset(null, -HALF);
            this.completed_check_mark.hide();
        }

        if (!is_defined(this.wall_entity_editor)) {<commit_msg>general updating 01<commit_after>'use strict';

const EDITOR_MODE_CREATE = 1;
const EDITOR_MODE_EDIT   = 2;

const ADD_NEW_FIELD_BUTTON_ROW = 'add_new_field_button';

const DELETABLE_ROW = 'deletable_row';

function EntityEditor(entity_wall) {
    this.__init__(entity_wall);
}

EntityEditor.prototype = {

    __init__: function(entity_wall_manager) {
        this.entity_wall_manager = entity_wall_manager;
        this.base_wall = this.entity_wall_manager.base_wall;
        this.world = this.base_wall.world;
        this.entity_wall = this.entity_wall_manager.entity_wall;

        this.current_mode = null;
    },

    entity_name_changed: function() {
        if (is_defined(this.current_mode)) {
            if (this.current_mode === EDITOR_MODE_EDIT) {
                this.wall_title.update_text('Editing : ' + this.entity_name_input.get_text());
            }
        }
    },

    create_or_save_changes_button_pressed: function() {
        if (this.current_mode === EDITOR_MODE_CREATE) {
            this._entity_created();
        } else {
            this._modify_entity();
        }
    },

    cancel_or_delete_button_pressed: function() {
        if (this.current_mode === EDITOR_MODE_CREATE) {
            this.wall_entity_editor.force_hide_self_and_all_child_attachments_recursively();
        } else {
            this.entity_wall_manager.delete_entity(this.entity_being_edited);
        }
    },

    delete_entity_field: function(field_name) {
        if (field_name === ENTITY_PROPERTY_START_DATE_TIME || field_name === ENTITY_PROPERTY_END_DATE_TIME) {
            this.date_selector.wall_date_selector.detach_from_parent();
            this.time_selector.wall_time_selector.detach_from_parent();
        } else if (field_name === ENTITY_PROPERTY_COMPLETED) {
            this.completed_check_mark.detach_from_parent();
        }
        this.wall_entity_editor.delete_row_by_name(field_name);

        if (this.current_mode === EDITOR_MODE_EDIT) {
            this.entity_being_edited.delete_property(field_name);
        }

        this.base_wall.refresh_position_and_look_at();
    },

    create: function(edit_mode) {
        if (!is_defined(this.date_selector)) {
            // Both creating a new entity and editing an existing entity will potentially need to utilize the date selector.
            this.date_selector = new DateSelector(this.world, this.date_selected.bind(this));
        }
        if (!is_defined(this.time_selector)) {
            // Both creating a new entity and editing an existing entity will potentially need to utilize the time selector.
            this.time_selector = new TimeSelector(this.world, this.time_selected.bind(this));
        }
        // Checkmark used in the completed field.
        if (!is_defined(this.completed_check_mark)) {
            this.completed_check_mark = new Floating2DText(16, ICON_CHECKMARK, TYPE_ICON, this.world);
            this.completed_check_mark.set_attachment_depth_offset(2);
            this.completed_check_mark.set_attachment_horizontal_offset(null, -HALF);
            this.completed_check_mark.set_to_invisible();
        }

        if (!is_defined(this.wall_entity_editor)) {
{'fraction_non_alphanumeric': 0.09394703656998739, 'fraction_numerical': 0.0022068095838587644, 'mean_word_length': 2.9385474860335195, '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': '144621', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1895, 'n_words': 292}