All files / output zcl_abapgit_gui_page_cr_repo.clas.mjs

14.09% Statements 21/149
66.66% Branches 2/3
16.66% Functions 1/6
14.09% Lines 21/149

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 1491x 1x 1x                                       1x 1x                                                                                                                                                                                                                           1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
const {zcl_abapgit_gui_component} = await import("./zcl_abapgit_gui_component.clas.mjs");
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_gui_page_cr_repo.clas.abap
class zcl_abapgit_gui_page_cr_repo extends zcl_abapgit_gui_component {
  static STATIC_SUPER = zcl_abapgit_gui_component;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_GUI_PAGE_CR_REPO';
  static IMPLEMENTED_INTERFACES = ["ZIF_ABAPGIT_GUI_EVENT_HANDLER","ZIF_ABAPGIT_GUI_RENDERABLE"];
  static ATTRIBUTES = {"MO_FORM": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_FORM", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_FORM"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MO_FORM_DATA": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_STRING_MAP", RTTIName: "\\CLASS=ZCL_ABAPGIT_STRING_MAP"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MO_VALIDATION_LOG": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_STRING_MAP", RTTIName: "\\CLASS=ZCL_ABAPGIT_STRING_MAP"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MO_FORM_UTIL": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_FORM_UTILS", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_FORM_UTILS"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "C_ID": {"type": () => {return new abap.types.Structure({
  "repo_type": new abap.types.String({qualifiedName: "STRING"}),
  "user_or_org": new abap.types.String({qualifiedName: "STRING"}),
  "name": new abap.types.String({qualifiedName: "STRING"}),
  "description": new abap.types.String({qualifiedName: "STRING"}),
  "private": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});}, "visibility": "I", "is_constant": "X", "is_class": "X"},
  "C_EVENT": {"type": () => {return new abap.types.Structure({
  "create": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});}, "visibility": "I", "is_constant": "X", "is_class": "X"}};
  static METHODS = {"GET_FORM_SCHEMA": {"visibility": "I", "parameters": {"RO_FORM": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_FORM", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_FORM"});}, "is_optional": " ", "parm_kind": "R", "type_name": "ObjectReferenceType"}}},
  "SET_DEFAULTS": {"visibility": "I", "parameters": {}},
  "CREATE": {"visibility": "U", "parameters": {"RI_PAGE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_GUI_RENDERABLE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_GUI_RENDERABLE"});}, "is_optional": " ", "parm_kind": "R", "type_name": "ObjectReferenceType"}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}},
  "CONSTRUCTOR": {"visibility": "U", "parameters": {"IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}}};
  #mo_form;
  #mo_form_data;
  #mo_validation_log;
  #mo_form_util;
  #mv_url;
  constructor() {
    const sup = super();
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "SUPER": sup.FRIENDS_ACCESS_INSTANCE,
      "get_form_schema": this.#get_form_schema.bind(this),
      "set_defaults": this.#set_defaults.bind(this),
    };
    this.#mo_form = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_FORM", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_FORM"});
    this.FRIENDS_ACCESS_INSTANCE["mo_form"] = this.#mo_form;
    this.#mo_form_data = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_STRING_MAP", RTTIName: "\\CLASS=ZCL_ABAPGIT_STRING_MAP"});
    this.FRIENDS_ACCESS_INSTANCE["mo_form_data"] = this.#mo_form_data;
    this.#mo_validation_log = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_STRING_MAP", RTTIName: "\\CLASS=ZCL_ABAPGIT_STRING_MAP"});
    this.FRIENDS_ACCESS_INSTANCE["mo_validation_log"] = this.#mo_validation_log;
    this.#mo_form_util = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_FORM_UTILS", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_FORM_UTILS"});
    this.FRIENDS_ACCESS_INSTANCE["mo_form_util"] = this.#mo_form_util;
    this.#mv_url = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_url"] = this.#mv_url;
    this.c_id = zcl_abapgit_gui_page_cr_repo.c_id;
    this.c_event = zcl_abapgit_gui_page_cr_repo.c_event;
  }
  async constructor_(INPUT) {
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    await super.constructor_();
    this.#mo_validation_log.set(await (new abap.Classes['ZCL_ABAPGIT_STRING_MAP']()).constructor_());
    this.#mo_form_data.set(await (new abap.Classes['ZCL_ABAPGIT_STRING_MAP']()).constructor_());
    this.#mo_form.set((await this.#get_form_schema()));
    this.#mo_form_util.set((await abap.Classes['ZCL_ABAPGIT_HTML_FORM_UTILS'].create({io_form: this.#mo_form})));
    this.#mv_url.set(iv_url);
    await this.#set_defaults();
    return this;
  }
  async create(INPUT) {
    return zcl_abapgit_gui_page_cr_repo.create(INPUT);
  }
  static async create(INPUT) {
    let ri_page = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_GUI_RENDERABLE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_GUI_RENDERABLE"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let lo_component = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_GUI_PAGE_CR_REPO", RTTIName: "\\CLASS=ZCL_ABAPGIT_GUI_PAGE_CR_REPO"});
    lo_component.set(await (new abap.Classes['ZCL_ABAPGIT_GUI_PAGE_CR_REPO']()).constructor_({iv_url: iv_url}));
    ri_page.set((await abap.Classes['ZCL_ABAPGIT_GUI_PAGE_HOC'].create({iv_page_title: abap.CharacterFactory.get(24, 'Create GitHub Repository'), ii_child_component: lo_component})));
    return ri_page;
  }
  async #get_form_schema() {
    let ro_form = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_FORM", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_FORM"});
    ro_form.set((await abap.Classes['ZCL_ABAPGIT_HTML_FORM'].create({iv_form_id: abap.CharacterFactory.get(24, 'create-github-repository')})));
    await (await (await (await (await (await (await (await (await ro_form.get().radio({iv_name: zcl_abapgit_gui_page_cr_repo.c_id.get().repo_type, iv_default_value: abap.builtin.abap_false, iv_label: abap.CharacterFactory.get(18, 'Type of Repository')})).get().option({iv_label: abap.CharacterFactory.get(4, 'User'), iv_value: abap.builtin.abap_false})).get().option({iv_label: abap.CharacterFactory.get(12, 'Organization'), iv_value: abap.builtin.abap_true})).get().text({iv_label: abap.CharacterFactory.get(20, 'User or Organization'), iv_name: zcl_abapgit_gui_page_cr_repo.c_id.get().user_or_org, iv_required: abap.builtin.abap_true})).get().text({iv_label: abap.CharacterFactory.get(15, 'Repository Name'), iv_name: zcl_abapgit_gui_page_cr_repo.c_id.get().name, iv_required: abap.builtin.abap_true})).get().text({iv_label: abap.CharacterFactory.get(11, 'Description'), iv_name: zcl_abapgit_gui_page_cr_repo.c_id.get().description})).get().checkbox({iv_label: abap.CharacterFactory.get(7, 'Private'), iv_name: zcl_abapgit_gui_page_cr_repo.c_id.get().private, iv_hint: abap.CharacterFactory.get(50, 'Set visibility to private (organization) or public')})).get().command({iv_label: abap.CharacterFactory.get(24, 'Create GitHub Repository'), iv_cmd_type: abap.Classes['ZIF_ABAPGIT_HTML_FORM'].zif_abapgit_html_form$c_cmd_type.get().input_main, iv_action: zcl_abapgit_gui_page_cr_repo.c_event.get().create})).get().command({iv_label: abap.CharacterFactory.get(4, 'Back'), iv_action: abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_action.get().go_back});
    return ro_form;
  }
  async #set_defaults() {
    let lv_rest = new abap.types.String({qualifiedName: "STRING"});
    let lv_org = new abap.types.String({qualifiedName: "STRING"});
    let lv_name = new abap.types.String({qualifiedName: "STRING"});
    abap.statements.find(this.#mv_url, {regex: abap.CharacterFactory.get(31, 'github\\.com\\/([^\\/]+)\\/([^\\/]+)'), first: false, submatches: [lv_org,lv_name]});
    if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
      await this.#mo_form_data.get().set({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().user_or_org, iv_val: lv_org});
      await this.#mo_form_data.get().set({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().name, iv_val: lv_name});
    }
    await this.#mo_form_data.get().set({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().private, iv_val: abap.builtin.abap_true});
  }
  async zif_abapgit_gui_event_handler$on_event(INPUT) {
    let rs_handled = new abap.types.Structure({
    "page": new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_GUI_RENDERABLE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_GUI_RENDERABLE"}),
    "state": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_GUI_EVENT_HANDLER=>TY_HANDLING_RESULT-STATE"})}, "zif_abapgit_gui_event_handler=>ty_handling_result", undefined, {}, {});
    let ii_event = INPUT?.ii_event;
    if (ii_event?.getQualifiedName === undefined || ii_event.getQualifiedName() !== "ZIF_ABAPGIT_GUI_EVENT") { ii_event = undefined; }
    if (ii_event === undefined) { ii_event = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_GUI_EVENT", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_GUI_EVENT"}).set(INPUT.ii_event); }
    let lv_url = new abap.types.String({qualifiedName: "STRING"});
    let lv_msg = new abap.types.String({qualifiedName: "STRING"});
    this.#mo_form_data.set((await this.#mo_form_util.get().normalize({io_form_data: (await ii_event.get().zif_abapgit_gui_event$form_data())})));
    let unique1146 = ii_event.get().zif_abapgit_gui_event$mv_action;
    if (abap.compare.eq(unique1146, zcl_abapgit_gui_page_cr_repo.c_event.get().create)) {
      this.#mo_validation_log.set((await this.#mo_form_util.get().validate({io_form_data: this.#mo_form_data})));
      if (abap.compare.eq((await this.#mo_validation_log.get().is_empty()), abap.builtin.abap_true)) {
        await abap.Classes['ZCL_ABAPGIT_HTTP'].create_by_url({iv_url: abap.CharacterFactory.get(33, 'https://api.github.com/user/repos')});
        lv_url.set(new abap.types.String().set(`https://github.com/${abap.templateFormatting((await this.#mo_form_data.get().get({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().user_or_org})))}/${abap.templateFormatting((await this.#mo_form_data.get().get({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().name})))}`));
        await (await abap.Classes['ZCL_ABAPGIT_PR_ENUMERATOR'].new({iv_url: lv_url})).get().create_repository({iv_description: (await this.#mo_form_data.get().get({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().description})), iv_is_org: new abap.types.String().set(`${abap.templateFormatting((await this.#mo_form_data.get().get({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().repo_type})))}`), iv_private: new abap.types.String().set(`${abap.templateFormatting((await this.#mo_form_data.get().get({iv_key: zcl_abapgit_gui_page_cr_repo.c_id.get().private})))}`)});
        lv_msg.set(new abap.types.String().set(`GitHub repository ${abap.templateFormatting(lv_url)} created successfully`));
        await abap.statements.message({exception: lv_msg, type: abap.CharacterFactory.get(1, 'S')});
        rs_handled.get().state.set(abap.Classes['ZCL_ABAPGIT_GUI'].c_event_state.get().go_back);
      } else {
        rs_handled.get().state.set(abap.Classes['ZCL_ABAPGIT_GUI'].c_event_state.get().re_render);
      }
    } else {
    }
    return rs_handled;
  }
  async zif_abapgit_gui_renderable$render() {
    let ri_html = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTML", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTML"});
    await this.register_handlers();
    ri_html.set((await abap.Classes['ZCL_ABAPGIT_HTML'].create()));
    await ri_html.get().zif_abapgit_html$add({ig_chunk: abap.CharacterFactory.get(28, '<div class="form-container">')});
    await ri_html.get().zif_abapgit_html$add({ig_chunk: (await this.#mo_form.get().render({io_values: this.#mo_form_data, io_validation_log: this.#mo_validation_log}))});
    await ri_html.get().zif_abapgit_html$add({ig_chunk: abap.CharacterFactory.get(6, '</div>')});
    return ri_html;
  }
}
abap.Classes['ZCL_ABAPGIT_GUI_PAGE_CR_REPO'] = zcl_abapgit_gui_page_cr_repo;
zcl_abapgit_gui_page_cr_repo.c_id = new abap.types.Structure({
"repo_type": new abap.types.String({qualifiedName: "STRING"}),
"user_or_org": new abap.types.String({qualifiedName: "STRING"}),
"name": new abap.types.String({qualifiedName: "STRING"}),
"description": new abap.types.String({qualifiedName: "STRING"}),
"private": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});
zcl_abapgit_gui_page_cr_repo.c_id.get().repo_type.set('repo_type');
zcl_abapgit_gui_page_cr_repo.c_id.get().user_or_org.set('user_or_org');
zcl_abapgit_gui_page_cr_repo.c_id.get().name.set('name');
zcl_abapgit_gui_page_cr_repo.c_id.get().description.set('description');
zcl_abapgit_gui_page_cr_repo.c_id.get().private.set('private');
zcl_abapgit_gui_page_cr_repo.c_event = new abap.types.Structure({
"create": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});
zcl_abapgit_gui_page_cr_repo.c_event.get().create.set('create');
export {zcl_abapgit_gui_page_cr_repo};