#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package AppUser::User::LabelList;

use strict;
use warnings;
use Data::Dumper;

use lib '/app/tools/appuser/lib';
use AppUser::DB::Item::UserClientLabelMap;

use lib '/app/tools/rps/lib';
use RPS::Label;

use lib '/app/tools/common/lib';
use Common::FormObject;
use Common::FormObject::SimpleHash;

use base 'Common::FormObject';

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);

    my $userID = $args{userID};
    $self->{_userID} = $userID;

    my $clientID = $args{clientID};
    $self->{_clientID} = $clientID;

    if ($userID) {
        my $collection = AppUser::DB::Item::UserClientLabelMap->GetByUserIDClientID( $userID, $clientID );
        while ( $collection->hasNext() ) {
            my $obj     = $collection->next();
            my $labelID = $obj->label_id;
            push @{ $self->{LabelID} }, $labelID;
        }
    }

    return $self;
}

sub _propertyIsEditable {
    my ( $self, $propertyName ) = @_;

    # The Product (and contained objects) can be edited.
    #
    if ( $propertyName eq 'LabelID' ) {
        return 1;
    }
    return 0;
}

sub LabelID {
    my $self = shift;

    if (@_) {
        my $newVal = shift @_;
        if ( ref($newVal) eq 'ARRAY' ) {
            $self->{LabelID} = $newVal;
        } else {
            $self->{LabelID} = [$newVal];
        }
    } else {
        return $self->{LabelID};
    }

    print STDERR "LABELID: " . Dumper( $self->{LabelID} ) . "\n";
}

sub getLabelIDs {
    my ($self) = @_;

    return $self->{LabelID};
}

###
1;    #
###

