Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MariagraziaAlastra committed Apr 1, 2015
2 parents 5cc5722 + 91eaf06 commit a7f764a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 26 deletions.
22 changes: 13 additions & 9 deletions lib/DDGC/Web/Controller/InstantAnswer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ sub ia_base :Chained('base') :PathPart('view') :CaptureArgs(1) { # /ia/view/cal
$can_edit = 1;

if ($is_admin) {
my $edits = get_edits($c->d, $c->stash->{ia}->name);
my $edits = get_edits($c->d, $answer_id);
$can_commit = 1;

if (length $edits && ref $edits eq 'HASH') {
Expand Down Expand Up @@ -455,7 +455,7 @@ sub ia_json :Chained('ia_base') :PathPart('json') :Args(0) {
status => $edited->{status},
example_query => $edited->{example_query},
other_queries => $edited->{other_queries}->{value},
topic => $edited->{topic},
topic => $edited->{topic}->{value},
dev_milestone => $edited->{dev_milestone},
tab => $edited->{tab},
producer => $edited->{producer},
Expand Down Expand Up @@ -805,7 +805,7 @@ sub create_ia :Chained('base') :PathPart('create') :Args() {
sub current_ia {
my ($d, $ia) = @_;

my $edits = get_edits($d, $ia->name);
my $edits = get_edits($d, $ia->id);

my @name = $edits->{'name'};
my @desc = $edits->{'description'};
Expand All @@ -832,6 +832,7 @@ sub current_ia {

if (ref $edits eq 'HASH') {
my $topic_val = $topic[0][@topic]{'value'};
my $topic_edited = $topic_val? 1 : undef;
my $other_q_val = $other_queries[0][@other_queries]{'value'};
my $other_q_edited = $other_q_val? 1 : undef;
my $developer_val = $developer[0][@developer]{'value'};
Expand All @@ -842,7 +843,7 @@ sub current_ia {
my $perl_dep_val = $perl_dependencies[0][@perl_dependencies]{'value'};
my $perl_dep_edited = $perl_dep_val? 1 : undef;

# Other queries, triggers and perl dependencies can be empty,
# Other queries, topics, triggers and perl dependencies can be empty,
# but the handlebars {{#if}} evaluates to false
# for both null and empty values,
# so instead of the value, we check the 'edited' key
Expand All @@ -852,6 +853,11 @@ sub current_ia {
value => $other_q_val? from_json($other_q_val) : undef
);

my %topics = (
edited => $topic_edited,
value => $topic_val? from_json($topic_val) : undef
);

my %triggers_hash = (
edited => $triggers_edited,
value => $triggers_val? from_json($triggers_val) : undef
Expand All @@ -866,7 +872,7 @@ sub current_ia {
name => $name[0][@name]{'value'},
description => $desc[0][@desc]{'value'},
status => $status[0][@status]{'value'},
topic => $topic_val? from_json($topic_val) : undef,
topic => \%topics,
example_query => $example_query[0][@example_query]{'value'},
other_queries => \%other_q,
dev_milestone => $dev_milestone[0][@dev_milestone]{'value'},
Expand Down Expand Up @@ -948,11 +954,9 @@ sub remove_edits {
# given the IA name return the data in the updates
# column as an array of hashes
sub get_edits {
my ($d, $name) = @_;

my $results = $d->rs('InstantAnswer')->search( {name => $name} );
my ($d, $id) = @_;

my $ia_result = $results->first();
my $ia_result = $d->rs('InstantAnswer')->find($id);
my $edits;

try{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ddg_community_platform",
"version": "0.69.0",
"version": "0.70.0",
"engines": {
"node": ">=0.10.0"
},
Expand Down
1 change: 1 addition & 0 deletions root/static/css/ddgc0.69.0.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions root/static/css/ia0.69.0.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions root/static/js/ddgc0.69.0.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions root/static/js/ia0.69.0.js

Large diffs are not rendered by default.

22 changes: 8 additions & 14 deletions src/ia/js/IAPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,21 +393,15 @@

$("body").on("click", ".button.delete", function(evt) {
if (ia_data.live.dev_milestone === "live") {
$(this).parent().remove();
var field = $(this).parent().find(".js-editable").attr('name');
if (field === 'example_query') {
var $new_primary = $('a.other-examples input').first();
if ($new_primary.length) {
$new_primary.parent().removeClass('other-examples');
$new_primary.parent().attr('name', 'example_query');
$new_primary.parent().attr('id', 'primary');
}
}

if (!$("#examples .other-examples").length && $("#primary").length) {
$("#primary").parent().find(".button.delete").addClass("hide");
var field = $(this).attr('name');
if (field !== "topic") {
$(this).parent().remove();
} else {
var $select = $(this).parent().find('.available_topics');
$select.find('option[value="0"]').empty();
$select.val('0');
}
} else {
} else {
// If dev milestone is not 'live' it means we are in the dev page
// and a topic has been deleted (it's the only field having a delete button in the dev page
// so far) - so we must save
Expand Down
Loading

0 comments on commit a7f764a

Please sign in to comment.