Skip to content

Commit

Permalink
Merge pull request #285 from CLOSER-Cohorts/release
Browse files Browse the repository at this point in the history
Fixes for issue #221 - Parent ids going missing. Improved error messa…
  • Loading branch information
spuddybike committed May 14, 2019
2 parents 3032302 + 171aa31 commit c02b94f
Show file tree
Hide file tree
Showing 326 changed files with 2,421 additions and 1,083 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ angular.module('archivist.build').controller(
$scope.cancel = ->
console.log "cancel called"
if $scope.newMode

$scope.editMode = $scope.newMode = false
else
$scope.reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,53 @@ angular.module('archivist.build').controller(
)
)

$scope.save = ->
$scope.save_construct = ->
arr = $scope.instrument.Constructs[$routeParams.construct_type.capitalizeFirstLetter() + 's']
console.log '<<<<<<<<'
console.log 'Arr variable: '
console.log arr
console.log '<<<<<<<<'
if $routeParams.construct_id == 'new'
console.info 'Adding a new construct'
arr.push $scope.current
index = arr.length - 1
arr[index].instrument_id = $routeParams.id
else
console.info 'Construct id: ' + $routeParams.construct_id
console.info 'Saving an existing construct'
console.log '-------------------------------------------------------'
console.log 'Current scope: '
console.log $scope.current
console.log '-------------------------------------------------------'
angular.copy $scope.current, arr.select_resource_by_id(parseInt($routeParams.construct_id))
index = arr.get_index_by_id parseInt($routeParams.construct_id)
console.log '-------------------------------------------------------'
console.log 'Array index: ' + index
console.log 'Parent id: ' + $scope.current.parent_id + ' | ' + 'Parent type: ' + $scope.current.parent_type
console.log '-------------------------------------------------------'
arr[index].save(
{}
,(value, rh)->
value['instrument_id'] = $scope.instrument.id
value['type'] = $routeParams.construct_type
Flash.add('success', 'Construct updated successfully!')

if $routeParams.construct_id == 'new'
parent = DataManager.Data.Instrument.Constructs[$scope.index.parent_type.capitalizeFirstLetter() + 's'].select_resource_by_id($scope.index.parent_id)
if $scope.index.branch == 0 or $scope.index.branch == null
parent.children.push arr[index]
else
parent.fchildren.push arr[index]

$scope.change_panel arr[index]

$scope.change_panel {type: null, id: null}
$scope.reset()
,->
Flash.add('danger', 'Construct failed to update')
console.error("Construct failed to update")
,(value, rh)->
value['instrument_id'] = $scope.instrument.id
value['type'] = $routeParams.construct_type
Flash.add('success', 'Construct updated successfully!')
console.info value

if $routeParams.construct_id == 'new'
parent = DataManager.Data.Instrument.Constructs[$scope.index.parent_type.capitalizeFirstLetter() + 's'].select_resource_by_id($scope.index.parent_id)
if $scope.index.branch == 0 or $scope.index.branch == null
parent.children.push arr[index]
else
parent.fchildren.push arr[index]

$scope.change_panel arr[index]


$scope.change_panel {type: null, id: null}
$scope.reset()
,->
Flash.add('danger', 'Construct failed to update')
console.error("Construct failed to update - save_construct (Cannot connect to Redis)")
)

$scope.reset = ->
Expand Down Expand Up @@ -192,6 +209,7 @@ angular.module('archivist.build').controller(
console.timeEnd 'after instrument'
console.timeEnd 'end to end'

# Saving response units
$scope.save_ru = (new_interviewee)->
DataManager.Data.ResponseUnits.push new DataManager.ResponseUnits.resource({
label: new_interviewee.label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
</form>

<button class="btn btn-danger" data-ng-if="!current.new" data-ng-click="delete()">Delete</button>
<button data-ng-show="detail.$dirty" data-ng-disabled="detail.$invalid" class="btn btn-primary" data-ng-click="save()">Save</button>
<button data-ng-show="detail.$dirty" data-ng-disabled="detail.$invalid" class="btn btn-primary" data-ng-click="save_construct()">Save</button>
5 changes: 5 additions & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ $icon-font-path: "bootstrap-sass/assets/fonts/bootstrap/";
.main {
padding: 0;
}

.breadcrumb {
border: 1px solid #d2d2d2;
}

@media (min-width: 768px) {
.main {
padding-right: 40px;
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/cc_conditions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class CcConditionsController < ConstructController
@model_class = CcCondition

# List of params that can be set and edited
@params_list = [:literal, :logic]
end
@params_list = [:id, :literal, :logic]
end
4 changes: 2 additions & 2 deletions app/controllers/cc_loops_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class CcLoopsController < ConstructController
@model_class = CcLoop

# List of params that can be set and edited
@params_list = [:loop_var, :start_val, :end_val, :loop_while]
end
@params_list = [:id, :loop_var, :start_val, :end_val, :loop_while]
end
4 changes: 2 additions & 2 deletions app/controllers/cc_questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CcQuestionsController < ConstructController
only_set_object { %i{variables set_topic add_variables remove_variable} }

@model_class = CcQuestion
@params_list = [:question_id, :question_type, :response_unit_id, :topic]
@params_list = [:id, :question_id, :question_type, :response_unit_id, :topic]

def variables
@collection ||= @object.variables
Expand Down Expand Up @@ -48,4 +48,4 @@ def remove_variable
format.json { render json: true, status: :accepted }
end
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/cc_sequences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class CcSequencesController < ConstructController
@model_class = CcSequence

# List of params that can be set and edited
@params_list = [:literal]
end
@params_list = [:id, :literal]
end
2 changes: 1 addition & 1 deletion app/controllers/cc_statements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class CcStatementsController < ConstructController
@model_class = CcStatement

# List of params that can be set and edited
@params_list = [:literal]
@params_list = [:id, :literal]
end
5 changes: 3 additions & 2 deletions app/controllers/construct_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ def safe_params
obj_name = self.class.model_class.name.underscore.to_sym
params = wrap_parent_param(self.params, obj_name)
params[obj_name] = shim_construct_type(params[obj_name])
# Do not add permition to :parent_type as it causes the parent_id to go missing
params.require( obj_name )
.permit( [:label, :parent_id, :parent_type, :position, :branch, :instrument_id] + self.class.params_list )
.permit( [:label, :parent_id, :position, :branch, :instrument_id] + self.class.params_list )
end

private
Expand Down Expand Up @@ -49,4 +50,4 @@ def wrap_parent_param(p, obj_name)
end
p
end
end
end
8 changes: 4 additions & 4 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def association_stats
begin
counts = $redis.get key
rescue Redis::CannotConnectError
Rails.logger.warn 'Cannot connect to Redis'
Rails.logger.warn 'Cannot connect to Redis [association_stats 1]'
end
if counts.nil?
counts = {}
Expand All @@ -72,7 +72,7 @@ def association_stats
begin
$redis.set key, counts.to_json
rescue Redis::CannotConnectError
Rails.logger.warn 'Cannot connect to Redis'
Rails.logger.warn 'Cannot connect to Redis [association_stats 2]'
end
else
counts = JSON.parse counts
Expand All @@ -90,7 +90,7 @@ def clear_cached_stats
begin
$redis.del key.classify + self.send(key).id.to_s + 'counts'
rescue Redis::CannotConnectError
Rails.logger.warn 'Cannot connect to Redis'
Rails.logger.warn 'Cannot connect to Redis [clear_cached_stats]'
end
end
end
Expand Down Expand Up @@ -122,7 +122,7 @@ def update_last_edit_time
$redis.hset 'last_edit:instrument', self.instrument.id, self.updated_at
end
rescue
Rails.logger.warn 'Cannot connect to Redis'
Rails.logger.warn 'Cannot connect to Redis [update_last_edit_time]'
end
end
end
15 changes: 13 additions & 2 deletions app/models/control_construct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,27 @@ def clear_cache
begin
unless self.parent_id.nil?
if self.parent_type == 'CcCondition'
$redis.ping
# puts 'Connecting to Redis...'
# puts "Id: #{self.id}"
# puts "Parent_id: #{self.parent_id}"
# puts "Parent_type: #{self.parent_type}"
$redis.hdel 'construct_children:CcCondition:0', self.parent_id
$redis.hdel 'construct_children:CcCondition:1', self.parent_id
else
$redis.ping
# puts 'Connecting to Redis...'
# puts "Id: #{self.id}"
# puts "Parent_id: #{self.parent_id}"
# puts "Parent_type: #{self.parent_type}"
$redis.hdel 'construct_children:' + self.parent_type, self.parent_id
end
end
$redis.hdel 'parents', self.id
$redis.hdel 'is_top', self.id
rescue
Rails.logger.warn 'Cannot connect to Redis'
rescue => err
Rails.logger.warn "Cannot connect to Redis [Control Construct] -> Error: '#{err}'"
exit 1
end
end

Expand Down
1 change: 0 additions & 1 deletion app/models/instrument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ def clear_cache
#
# @return [Instrument] Returns the newly copied instrument
def copy(new_prefix, other_vals = {})

new_i = self.dup
new_i.prefix = new_prefix
other_vals.select { |key, val| new_i[key] = val }
Expand Down
2 changes: 1 addition & 1 deletion app/models/strand.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def self.find_by_member(member)
begin
@id ||= redis.hget LOOKUP, member.typed_id
rescue Redis::CannotConnectError
Rails.logger.warn 'Cannot connect to Redis'
Rails.logger.warn 'Cannot connect to Redis [find_by_member]'
end
return nil if @id.nil?
return Strand.find(@id.to_i)
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Archivist
class Application
VERSION = '10.5.6'
VERSION = '10.5.7'
BETA = false
end
end

Large diffs are not rendered by default.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11273,87 +11273,92 @@ div.vis-color-picker input.vis-saturation-range {
padding: 0;
}

/* line 70, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.breadcrumb {
border: 1px solid #d2d2d2;
}

@media (min-width: 768px) {
/* line 70, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 75, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.main {
padding-right: 40px;
padding-left: 40px;
}
}
/* line 75, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 80, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.main .page-header {
margin-top: 0;
}

/* line 79, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 84, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.tab-pane > form > .form-group:first-child {
margin-top: 15px;
}

/* line 83, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 88, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.unselectable {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

/* line 90, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 95, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.transparent {
color: transparent;
}

/* line 94, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 99, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.invisible {
visibility: hidden;
}

/* line 98, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 103, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
background-color: #eeeeee !important;
}

/* line 102, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 107, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.bg-purple {
background: #652C90;
}

/* line 106, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 111, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.bg-blue {
background: #00ADEF;
}

/* line 110, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 115, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.bg-green {
background: #38B449;
}

/* line 114, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 119, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.bg-pink {
background: #EC008B;
}

/* line 118, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 123, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.bg-orange {
background: #FBAF3F;
}

/* line 122, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 127, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
p.rt-online {
color: #3c763d !important;
}

/* line 126, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 131, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
p.rt-offline {
color: #a94442 !important;
}

/* line 130, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 135, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.tree-boot li.tree-leaf i.tree-leaf-head {
background: url(/images/file.png);
}

/* line 134, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 139, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
#overlay {
height: 100%;
width: 100%;
Expand All @@ -11363,18 +11368,18 @@ p.rt-offline {
z-index: -10000;
}

/* line 144, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 149, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
#overlay.loading {
background: rgba(50, 50, 50, 0.5);
z-index: 10000;
}

/* line 149, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 154, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.a-tree-placeholder {
background: #428bca;
}

/* line 153, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
/* line 158, /Users/qtnvcd8/Cloned/archivist/app/assets/stylesheets/application.css.scss */
.a-tree-hidden,
.a-tree-drag {
display: none;
Expand Down
Binary file not shown.
Loading

0 comments on commit c02b94f

Please sign in to comment.