Added rfe #9098 Thingy thing-copy function and added some context to thingy's i18n
This commit is contained in:
parent
d8fdd6d7df
commit
a57fc80a18
6 changed files with 135 additions and 2 deletions
|
|
@ -308,6 +308,42 @@ sub duplicate {
|
|||
return $newAsset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicateThing ( thingId )
|
||||
|
||||
Duplicates a thing.
|
||||
|
||||
=head3 thingId
|
||||
|
||||
The id of the Thing that will be duplicated.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicateThing {
|
||||
|
||||
my $self = shift;
|
||||
my $oldThingId = shift;
|
||||
my $db = $self->session->db;
|
||||
|
||||
my $thingProperties = $self->getThing($oldThingId);
|
||||
$thingProperties->{thingId} = 'new';
|
||||
$thingProperties->{label} = $thingProperties->{label}.' (copy)';
|
||||
|
||||
my $newThingId = $self->addThing($thingProperties);
|
||||
my $fields = $db->buildArrayRefOfHashRefs('select * from Thingy_fields where assetId=? and thingId=?'
|
||||
,[$self->getId,$oldThingId]);
|
||||
foreach my $field (@$fields) {
|
||||
# set thingId to newly created thing's id.
|
||||
$field->{thingId} = $newThingId;
|
||||
$self->addField($field,0);
|
||||
}
|
||||
|
||||
return $newThingId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteField ( fieldId , thingId )
|
||||
|
|
@ -1436,6 +1472,26 @@ sub www_deleteFieldConfirm {
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_duplicateThing ( )
|
||||
|
||||
Duplicates a Thing.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_duplicateThing {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $thingId = $session->form->process("thingId");
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
|
||||
$self->duplicateThing($thingId);
|
||||
|
||||
return $self->www_manage;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_copyThingData( )
|
||||
|
|
@ -2868,6 +2924,8 @@ sub www_manage {
|
|||
"",$i18n->get('delete thing warning')),
|
||||
'thing_editUrl' => $session->url->append($url, 'func=editThing;thingId='.$thing->{thingId}),
|
||||
'thing_editIcon' => $session->icon->edit('func=editThing;thingId='.$thing->{thingId}),
|
||||
'thing_copyUrl' => $session->url->append($url, 'func=duplicateThing;thingId='.$thing->{thingId}),
|
||||
'thing_copyIcon' => $session->icon->copy('func=duplicateThing;thingId='.$thing->{thingId}),
|
||||
'thing_addUrl' => $session->url->append($url,
|
||||
'func=editThingData;thingId='.$thing->{thingId}.';thingDataId=new'),
|
||||
'thing_searchUrl' => $session->url->append($url, 'func=search;thingId='.$thing->{thingId}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue