Sencha Touch locale file issue - sencha-touch

Ok, my file structure looks like the following:
http://imgur.com/BInIbEY
And it seems to be building fine without changing everything like i did before.
Now i have an issue with ext-lang-es.js. Is the localization file i found somewhere in the forums that worked great:
Ext.onReady(function() {Ext.Date.dayNames = [
'Domingo',
'Lunes',
'Martes',
'Miercoles',
'Jueves',
'Viernes',
'Sabado'
];
Ext.Date.monthNames = [
'Enero',
'Febrero',
'Marzo',
'Abril',
'Mayo',
'Junio',
'Julio',
'Agosto',
'Septiembre',
'Octubre',
'Noviembre',
'Diciembre'
];
Ext.Date.monthNumbers = {
'Jan': 0,
'Feb': 1,
'Mar': 2,
'Apr': 3,
'Maj': 4,
'Jun': 5,
'Jul': 6,
'Avg': 7,
'Sep': 8,
'Okt': 9,
'Nov': 10,
'Dec': 11
};
Ext.Date.getShortMonthName = function(month) {
return Date.monthNames[month].substring(0, 3);
};
Ext.Date.getShortDayName = function(day) {
return Date.dayNames[day].substring(0, 3);
};
Ext.Date.getMonthNumber = function(name) {
return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
};
//Ext.Date.parseCodes.S.s = '(?:st|nd|rd|th)';
if (Ext.picker.Picker){
Ext.define('Ext.picker.Picker', {
override: 'Ext.picker.Picker',
config:{
doneButton: 'Listo' ,
cancelButton: 'Cancelar'
}
});
}
if (Ext.picker.Date) {
//debugger;
Ext.define('Ext.picker.Date', {
override: 'Ext.picker.Date',
config:{
doneButton: 'Listo' ,
cancelButton: 'Cancelar',
dayText: 'Dia',
monthText: 'Mes',
yearText: 'Año',
slotOrder: ['day', 'month', 'year']
}
});
}
if(Ext.IndexBar){
Ext.define('Ext.IndexBar', {
override: 'Ext.IndexBar',
config:
{
letters: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
}
});
}
if(Ext.NestedList){
Ext.define('Ext.NestedList', {
override: 'Ext.NestedList',
config:{
backText: 'Volver',
loadingText: 'Cargando...',
emptyText: 'Sin registros'
}
});
}
if(Ext.util.Format){
Ext.util.Format.defaultDateFormat = 'd/m/Y';
}
if(Ext.MessageBox){
Ext.MessageBox.OK.text = 'OK';
Ext.MessageBox.CANCEL.text = 'Cancelar';
Ext.MessageBox.YES.text = 'Si';
Ext.MessageBox.NO.text = 'No';
}
});
but now i get "Uncaught Error: The following classes are not declared even if their files have been loaded: 'Ext.picker.Date', 'Ext.picker.Picker'. Please check the source code of their corresponding files for possible typos: 'app/ext-lang-es.js', 'app/ext-lang-es.js"
after building the app
So... what did i do wrong? should i put the locale file somewhere else? I also tried adding it to the "js" section of app.json, but it's the same...

Related

How to extract second level keys out of two level map using lodash

I have a data structure like this
{
'a' : { 'aa' : { b: 1, c: 2}},
'b' : { 'bb' : { c: 3, d: 4}},
'c' : { 'cc' : { c: 3, d: 4}}
}
I'd like to map it using lodash into a flat structure like this:
{
'aa' : { b: 1, c: 2}},
'bb' : { c: 3, d: 4}},
'cc' : { c: 3, d: 4}},
}
I can do it using a side effect based approach with the code like this:
const flattened = {};
_(state.values)
.map(e => _.forEach(e, (e, k) => flattened[k] = e))
.value();
It does the job, but I am looking for a nicer pure functional way to do this.
Get the values of the original object, and merge them into a new object:
const obj = {
'a' : { 'aa' : { b: 1, c: 2}},
'b' : { 'bb' : { c: 3, d: 4}},
'c' : { 'cc' : { c: 3, d: 4}}
}
const result = _.merge({}, ..._.values(obj))
console.log(result)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js" integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

How to merge objects with Lodash, but replace arrays values?

I'm trying to replace arrays of an old object with values from a new object which has arrays... I guess it will make sense when you see an example and desire result:
https://jsfiddle.net/redlive/9coq7dmu/
const oldValues = {
a: 1,
b: [2, 21, 22, 23],
c: {
d: 3,
e: 4,
f: [5, 6, 7]
}
};
const updatedValues = {
b: [],
c: {
f: [8]
}
}
const result = _.merge( oldValues, updatedValues );
console.log(result);
/* Desire result:
{
a: 1,
b: [],
c: {
d: 3,
e: 4,
f: [8]
}
}
*/
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js"></script>
Use _.mergeWith(), and if the 2nd value is an array, return it. If not return undefined, and let merge handle it:
const oldValues = {"a":1,"b":[2,21,22,23],"c":{"d":3,"e":4,"f":[5,6,7]}};
const updatedValues = {"b":[],"c":{"f":[8]}};
const result = _.mergeWith(oldValues, updatedValues, (a, b) =>
_.isArray(b) ? b : undefined
);
console.log(result);
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js"></script>

Reducing to list of object from object key and value

Given a previous Ramda groupBy to
{
'2018-Q4': 2,
'2019-Q1': 5
}
How can I map this to
[
{'quarter': '2018-Q4', 'value': 2},
{'quarter': '2019-Q1', 'value': 5},
]
Convert to pairs and then zipObj with the field names:
const { pipe, toPairs, map, zipObj } = R
const fn = pipe(
toPairs,
map(zipObj(['quarter', 'value']))
)
const data = {
'2018-Q4': 2,
'2019-Q1': 5
}
const result = fn(data)
console.log(result)
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.0/ramda.js"></script>

How do i view the parsed json data from odoo api in the listview?

i am not able to view the json in the listview. it might be a problem with return type. The list i.e 'users' I am returning doesn't return any data, so when i call the function in the FutureBuilder widget, i get null.
OdooResponse result;
List<Saleslist> users = [];
Future<List<Saleslist>> _getOrders() async {
var client = OdooClient("http://192.168.1.108:8050");
final domain = [
// ["sale_ok", "!=", false]
];
var fields = ["id", "name"];
// var fields = ["id", "name", "confirmation_date"];
client
.authenticate("admin", "admin", "flutterodoo11")
.then((AuthenticateCallback auth) async {
if (auth.isSuccess) {
final user = auth.getUser();
print("Hey ${user.name}");
} else {
// login fail
print("Login failed");
}
client
.searchRead("sale.order", domain, fields)
.then((OdooResponse result) {
if (!result.hasError()) {
print("Succesful");
var response = result.getResult();
var encoded = json.encode(response['records']);
data = encoded;
var convertDataToJson = json.decode(encoded);
data = convertDataToJson;
print(data);
for (var u in data) {
print(u);
Saleslist user = Saleslist(u["name"], u["id"]);
users.add(user);
}
} else {
print(result.getError());
}
print(users.length);
});
});
return users;
}
This is the code for Future Builder
child: FutureBuilder(
future: _getOrders(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.data == null) {
print(data);
return Container(
child: Center(
child: CircularProgressIndicator(),
));
} else {
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: snapshot.data.length,
itemBuilder: (context, int index) {
return ListTile(
title: Text(snapshot.data.name),
);
});
}
// }
}),
),
This is the json i get from the odoo_api
[{id: 1, name: SO001}, {id: 2, name: SO002}, {id: 3, name: SO003}, {id: 5, name: SO005}, {id: 4, name: SO004}, {id: 7, name: SO007}, {id: 9, name: SO008}, {id: 10, name: SO009}, {id: 6, name: SO006}, {id: 8, name: Test/001}, {id: 11, name: SO010}, {id: 12, name: SO011}, {id: 13, name: SO012}, {id: 14, name: SO013}, {id: 15, name: SO014}, {id: 16, name: SO015}, {id: 17, name: SO016}, {id: 18, name: SO017}, {id: 19, name: SO018}, {id: 20, name: SO019}]
EDIT:
Now i'm getting "Another exception was thrown: type 'List' is not a subtype of type 'String'" error... i added the await method, but the FutureBuilder widget is the same.
var client = OdooClient("http://192.168.1.34:8050");
List<Saleslist> users = [];
var data;
OdooResponse result;
Future<List<Saleslist>> _getOrders() async {
final domain = [
// ["sale_ok", "!=", false]
];
var fields = ["id", "name"];
// var fields = ["id", "name", "confirmation_date"];
await client
.authenticate("admin", "admin", "flutterodoo11")
.then((AuthenticateCallback auth) async {
if (auth.isSuccess) {
final user = auth.getUser();
print("Hey ${user.name}");
} else {
// login fail
print("Login failed");
}
await client
.searchRead("sale.order", domain, fields)
.then((OdooResponse result) {
if (!result.hasError()) {
print("Succesful");
var response = result.getResult();
var encoded = json.encode(response['records']);
// data = json.encode(encoded);
data = json.decode(encoded);
print(data);
for (var u in data) {
// print(u);
Saleslist user = Saleslist(u["name"], u["id"]);
users.add(user);
}
} else {
print(result.getError());
}
});
});
print(users.length);
return (users);
}
Usign await instead of then() solved the return type (i think) issue.
var client = OdooClient("http://192.168.1.108:8050");
Future<List<Saleslist>> _getOrders() async {
// List<Saleslist> users = [];
final domain = [];
// var fields = ["id", "name"];
var fields = ["id", "name", "confirmation_date", "partner_id"];
AuthenticateCallback auth =
await client.authenticate("admin", "admin", "flutterodoo11");
if (auth.isSuccess) {
final user = auth.getUser();
print("Hey ${user.name}");
} else {
// login fail
print("Login failed");
}
OdooResponse result = await client.searchRead("sale.order", domain, fields);
if (!result.hasError()) {
print("Successful");
var response = result.getResult();
var data = json.encode(response['records']);
// data = json.encode(encoded);
var decoded = json.decode(data);
print(data);
List<Saleslist> users = [];
for (var u in decoded) {
// print(u);
Saleslist user = Saleslist(u["name"], u["id"]);
print(user);
users.add(user);
}
return users;
} else {
print(result.getError());
}
}
The snapshot.data was a string when "List" type was expected. Thus changing it as "snapshot.data[index].name" solved the entire issue of not showing data in the list view.
FutureBuilder(
future: _getOrders(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
print(snapshot.data);
if (snapshot.data == null) {
// print(snapshot.data);
return Container(
child: Center(child: CircularProgressIndicator()));
} else {
return SizedBox(
// height: 500,
child: ListView.builder(
// scrollDirection: Axis.vertical,
itemCount: snapshot.data.length,
itemBuilder: (context, int index) {
return Card(
child: ListTile(
leading: Icon(Icons.history),
title: Text(
snapshot.data[index].name,
style: TextStyle(
fontSize: 25,
// fontFamily: "Hand_Of_Sean_Demo",
),
),
// subtitle: Text(snapshot.data[index].partner_id),
),
);
}),
);
}
// }
}),

tcpdf edit footer

How do I edit a footer using tcpdf? I want to add current date & time at the footer. Please help.
Override the class like this :
class MYPDF extends TCPDF {
public function Footer() {
$image_file = "img/bg_bottom_releve.jpg";
$this->Image($image_file, 11, 241, 189, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
$this->SetY(-15);
$this->SetFont('helvetica', 'N', 6);
$this->Cell(0, 5, date("m/d/Y H\hi:s"), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
then instead of calling :
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
do :
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
You have to extend the TCPDF class and override the Footer() method as explained on the default example n. 3. Check the official http://www.tcpdf.org website and forums for further information.
How can I create 2 footer lines, please?
class MYPDF extends TCPDF {
private $customFooterText = "";
/**
* #param string $customFooterText
*/
public function setCustomFooterText($customFooterText)
{
$this->customFooterText = $customFooterText;
}
public function Footer()
{
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0, 10, $this->customFooterText, 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
Usage
$pdf = new MYPDF();
$pdf->setCustomFooterText('THIS IS CUSTOM FOOTER');
If you want dynamically change footer text extends TCPDF like this
class MYPDF extends TCPDF {
private $customFooterText = "";
/**
* #param string $customFooterText
*/
public function setCustomFooterText($customFooterText)
{
$this->customFooterText = $customFooterText;
}
public function Footer()
{
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0, 10, $this->customFooterText, 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
usage:
$pdf = new MYPDF();
$pdf->setCustomFooterText('THIS IS CUSTOM FOOTER');
// .... etc
If you want put an different content on more than one page:
define("bottom_info", "|FIRST PAGE|SECOND PAGE|THIRD PAGE|...", true);
the info will be separated by " | " (with explode function)
class:
class MYPDF extends TCPDF {
public function Header() {
}
// Page footer
public function Footer() {
$this->SetY(-15);
$this->SetFont('helvetica', '', 7);
// Page number
$titulos = explode("|",bottom_info);
$this->Cell(0, 10, $titulos[$this->page].' - Pagina '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
After the EOD use the below code to overwrite the footer method.
EOD;
$txt = date("m/d/Y h:m:s");
// print a block of text using Write()
$pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0);
I figured it out and here's the solution for others that might come across this thread.
Edit the file "tcpdf.php".
Search for "public function Footer()"
Add timestamp here:
$timestamp = date("m/d/Y h:m:s");
if (empty($this->pagegroups)) {
$pagenumtxt = ' Created on ' .$timestamp.' '.$this->l['w_page'].' '.$this->getAliasNumPage().' / '.$this->getAliasNbPages();
} else {
$pagenumtxt = ' Created on ' .$timestamp.' '. $this->l['w_page'].' '.$this->getPageNumGroupAlias().' / '.$this->getPageGroupAlias();
}