0% found this document useful (0 votes)
15 views3 pages

App Controller

Uploaded by

ogun.271010
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

App Controller

Uploaded by

ogun.271010
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

[Link].

define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/m/MessageToast",
"sap/m/MessageBox"
], function (Controller, JSONModel, MessageToast, MessageBox) {
"use strict";

return [Link]("[Link]", {

onInit: function () {
this._data = {
Preview: [],
SelectedCount: 0,
SelectedText: "0/10 selected"
};
[Link]().setModel(new JSONModel(this._data));

this._selectedFile = null; // CSV dosyasını burada saklayacağız


},

onSearch: function () {
const fileInput = [Link]("input");
[Link] = "file";
[Link] = ".csv";

[Link] = (e) => {


const file = [Link][0];
if (!file) return;

// Dosya adını input'a yaz


[Link]("filePathInput").setValue([Link]);

// Dosyayı sakla
this._selectedFile = file;

// Butonları aktif et
[Link]("uploadBtn").setEnabled(true);
[Link]("cancelBtn").setEnabled(true);
};

[Link]();
},

onUpload: function () {
const file = this._selectedFile;
if (!file) {
[Link]("Lütfen önce bir CSV dosyası seçin.");
return;
}

const reader = new FileReader();


[Link] = (event) => {
const content = [Link];
const rows = [Link]("\n").map(r => [Link]()).filter(Boolean);
const data = [Link](1).map(row => {
const cells = [Link](",");
return {
ID: parseInt(cells[0]),
Avatar: cells[1],
Name: cells[2],
Birthday: cells[3],
};
});

this._data.Preview = data;
this._data.Filtered = data;
this._data.Backup = [Link]([Link](data));

this._data.SelectedCount = [Link]; // 🔥 EKLENDİ


this._data.SelectedText = `${[Link]}/10 selected`;

[Link]().getModel().refresh(); // Modeli güncelle


};

[Link](file);
}
,

onCancel: function () {
this._data.Preview = [];
this._data.SelectedCount = 0;
this._data.SelectedText = "0/10 selected";
[Link]().getModel().refresh();

// Input'u ve dosya referansını sıfırla


[Link]("filePathInput").setValue("");
this._selectedFile = null;

[Link]("uploadBtn").setEnabled(false);
[Link]("cancelBtn").setEnabled(false);
},

onImport: function () {
const data = this._data.Preview;
if ([Link] === 0) {
[Link]("İçe aktarılacak veri yok.");
return;
}

// 🔄 DÜZGÜN YAPI: Preview alanına veri atanıyor


const oGlobalModel = new [Link]({
Preview: data,
Filtered: data,
SelectedText: [Link] + " kayıt"
});

// 🌍 Global modele aktar


[Link]().setModel(oGlobalModel, "Kisiler");

// 🔁 Yönlendirme
const oRouter = [Link](this);
[Link]("kayitlar");

[Link]("Veriler kayıtlar sayfasına aktarıldı.");


}
});
});

You might also like