|
Lines 148-153
__PACKAGE__->has_many(
Link Here
|
| 148 |
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-02-22 14:32:48 |
148 |
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-02-22 14:32:48 |
| 149 |
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hDlebhEn+f+thqwBo/LOqQ |
149 |
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hDlebhEn+f+thqwBo/LOqQ |
| 150 |
|
150 |
|
| 151 |
|
151 |
__PACKAGE__->load_components('+Koha::DBIx::Component::L10nSource'); |
| 152 |
# You can replace this text with custom code or comments, and it will be preserved on regeneration |
152 |
|
|
|
153 |
sub insert { |
| 154 |
my $self = shift; |
| 155 |
|
| 156 |
my $result = $self->next::method(@_); |
| 157 |
|
| 158 |
my @authorised_values = $self->result_source->resultset->search(undef, { |
| 159 |
result_class => 'DBIx::Class::ResultClass::HashRefInflator', |
| 160 |
columns => ['lib', 'lib_opac'], |
| 161 |
}); |
| 162 |
my @sources = map { $_->{lib}, $_->{lib_opac} } @authorised_values; |
| 163 |
my $category = $self->get_column('category'); |
| 164 |
my $context = "authorised_value:$category"; |
| 165 |
$self->update_l10n_source($context, @sources); |
| 166 |
|
| 167 |
return $result; |
| 168 |
} |
| 169 |
|
| 170 |
sub update { |
| 171 |
my $self = shift; |
| 172 |
|
| 173 |
my $is_lib_changed = $self->is_column_changed('lib') || $self->is_column_changed('lib_opac'); |
| 174 |
|
| 175 |
my $result = $self->next::method(@_); |
| 176 |
|
| 177 |
if ($is_lib_changed) { |
| 178 |
my $category = $self->get_column('category'); |
| 179 |
my @authorised_values = $self->result_source->resultset->search( |
| 180 |
{ category => $category }, |
| 181 |
{ |
| 182 |
result_class => 'DBIx::Class::ResultClass::HashRefInflator', |
| 183 |
columns => ['lib', 'lib_opac'], |
| 184 |
} |
| 185 |
); |
| 186 |
my @sources = map { $_->{lib}, $_->{lib_opac} } @authorised_values; |
| 187 |
my $context = "authorised_value:$category"; |
| 188 |
$self->update_l10n_source($context, @sources); |
| 189 |
} |
| 190 |
|
| 191 |
return $result; |
| 192 |
} |
| 193 |
|
| 194 |
sub delete { |
| 195 |
my $self = shift; |
| 196 |
|
| 197 |
my $result = $self->next::method(@_); |
| 198 |
|
| 199 |
my @authorised_values = $self->result_source->resultset->search(undef, { |
| 200 |
result_class => 'DBIx::Class::ResultClass::HashRefInflator', |
| 201 |
columns => ['lib', 'lib_opac'], |
| 202 |
}); |
| 203 |
my @sources = map { $_->{lib}, $_->{lib_opac} } @authorised_values; |
| 204 |
my $category = $self->get_column('category'); |
| 205 |
my $context = "authorised_value:$category"; |
| 206 |
$self->update_l10n_source($context, @sources); |
| 207 |
|
| 208 |
return $result; |
| 209 |
} |
| 153 |
1; |
210 |
1; |