Commit 8e62c75e authored by Kerenoc's avatar Kerenoc

ImportGCstar : add option to overwrite items instead of duplicating

parent c09eca2c
......@@ -529,11 +529,25 @@ use strict;
$self->displayCurrent;
}
sub writeItem
{
my ($self, $idx, $info) = @_;
for my $field (@{$self->{model}->{fieldsNames}})
{
next if $field eq $self->{model}->{commonFields}->{id};
if ($self->{model}->{fieldsInfo}->{$field}->{hasHistory})
{
$self->{panel}->{$field}->addHistory($info->{$field});
}
$self->{itemArray}->[$idx]->{$field} = $info->{$field};
}
}
sub addItem
{
my ($self, $info, $keepId, $noSelect) = @_;
my $nbItems = scalar @{$self->{itemArray}};
# $self->{panel}->show if ! $nbItems;
my $currentId;
if ($keepId)
......@@ -813,7 +827,6 @@ use strict;
}
$self->{panel}->{$hfield}->setDropDown;
}
# $self->{loaded}->{gotHistory} = 2;
}
elsif ($self->{loaded}->{gotHistory} == 2)
{
......@@ -910,15 +923,15 @@ use strict;
# We re-generate histories to give it to backend
# Deactivated for the moment
# if ($self->{panel})
# {
# my %histories;
# for my $hfield(@{$self->{model}->{fieldsHistory}})
# {
# $histories{$hfield} = $self->{panel}->{$hfield}->getValues;
# }
# $backend->setHistories(\%histories);
# }
# if ($self->{panel})
# {
# my %histories;
# for my $hfield(@{$self->{model}->{fieldsHistory}})
# {
# $histories{$hfield} = $self->{panel}->{$hfield}->getValues;
# }
# $backend->setHistories(\%histories);
# }
my $result = $backend->save($self->{itemArray},
$self->{loaded}->{information},
......
......@@ -158,9 +158,26 @@ use GCExportImport;
}
my $generateId = $self->generateId;
foreach (@tmpArray)
foreach my $info(@tmpArray)
{
$options->{parent}->{items}->addItem($_, !$generateId, 1);
my $itemExists = 0;
if ($options->{overwriteItems})
{
# overwrite the first items with the same title
my $nbItems = scalar @{$options->{parent}->{items}->{itemArray}};
my $titleName = $self->{model}->{commonFields}->{title};
for (my $i=0; $i < $nbItems && ! $itemExists; $i++) {
if ($info->{$titleName} eq $options->{parent}->{items}->{itemArray}[$i]->{$titleName})
{
$itemExists = 1;
$options->{parent}->{items}->writeItem($i,$info);
}
}
}
if (! $itemExists)
{
$options->{parent}->{items}->addItem($info, !$generateId, 1);
}
}
$options->{parent}->{items}->unselect;
$self->{options}->{parent}->restoreCursor;
......
......@@ -65,6 +65,12 @@ use GCImport::GCImportBase;
type => 'yesno',
label => 'CopyPictures',
default => '1'
},
{
name => 'overwriteItems',
type => 'yesno',
label => 'OverwriteItems',#.$self->{model}->{fieldsInfo}->{title}->{displayed}, #$self->{model}->{commonFields}->{title},
default => '0'
}];
}
......
......@@ -43,6 +43,7 @@
our %lang = (
'CopyPictures' => 'نسخ الصور',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copy pictures',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copia les imatges',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Kopírovat obrázky',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Kopiere Bilder',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Αντιγραφή εικόνων',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copy pictures',
'OverwriteItems' => 'Overwrite items with the same names',
);
}
......
......@@ -31,6 +31,8 @@
our %lang = (
'CopyPictures' => 'Copier les images',
'OverwriteItems' => 'Ecraser les éléments avec le même nom',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copiar imaxes',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Képek másolása',
'OverwriteItems' => 'Overwrite items with similar items',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Salin gambar',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -38,6 +38,7 @@
our %lang = (
'CopyPictures' => 'Copia immagini',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Kopieer afbeeldingen',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Kopiuj obrazy',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copiar imagens',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copiază imaginile',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Копировать изображения',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copy pictures',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Kopiera bilder',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Copy pictures',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => 'Копіювати зображення',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => '複製圖片',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
......@@ -31,6 +31,7 @@
our %lang = (
'CopyPictures' => '复制图片',
'OverwriteItems' => 'Overwrite items with similar names',
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment