Skip to content

Commit 59e1d60

Browse files
committed
feat: Remove OCDS Show
1 parent 93b3440 commit 59e1d60

File tree

11 files changed

+411
-1017
lines changed

11 files changed

+411
-1017
lines changed

cove_ocds/locale/en/LC_MESSAGES/django.po

Lines changed: 190 additions & 218 deletions
Large diffs are not rendered by default.

cove_ocds/locale/es/LC_MESSAGES/django.po

Lines changed: 221 additions & 228 deletions
Large diffs are not rendered by default.

cove_ocds/sass/_custom-ocds.sass

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ a.view-all
137137
text-decoration: none;
138138

139139

140-
.release-badge.success
141-
background-color: #676C3F !important
142-
.release-badge.primary
143-
background-color: #9baf00 !important
144-
145140
#container .panel
146141
&-body dt
147142
color: $gray;

cove_ocds/templates/cove_ocds/explore_base.html

Lines changed: 0 additions & 312 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
<a href="{% url 'index' %}" class="btn btn-large btn-success">{% trans 'Load New File' %}</a>
66
{% endblock %}
77

8-
{% block after_head %}
9-
{{block.super}}
10-
<link href="https://cdn.jsdelivr.net/gh/open-contracting/ocds-show@v0.2.1/css/custom.css" rel="stylesheet">
11-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/marianoguerra/json.human.js@0.1.1/css/json.human.css">
12-
{% endblock %}
13-
148
{% block explore_content %}
159
<div class="row">
1610

@@ -526,310 +520,4 @@ <h2>{% trans "Save or Share these results" %}</h2>
526520
$('#small-loading').css({"display": "inline"});
527521
});
528522
</script>
529-
<script src="https://vega.github.io/vega/vega.min.js"></script>
530-
531-
<script src="https://cdn.jsdelivr.net/gh/open-contracting/ocds-show@v0.2.1/js/nunjucks.min.js"></script>
532-
<script src="https://cdn.jsdelivr.net/gh/open-contracting/ocds-show@v0.2.1/js/merge.min.js"></script>
533-
<script src="https://cdn.jsdelivr.net/gh/open-contracting/ocds-show@v0.2.1/templates.js"></script>
534-
<script src="https://cdn.jsdelivr.net/gh/marianoguerra/json.human.js@0.1.1/src/json.human.js"></script>
535-
<script>
536-
var jsonInput = $('#input-json')
537-
var container = $('#container')
538-
var jsonInputView = function() {
539-
return !$("#input-json-container").hasClass("hide")
540-
}
541-
542-
var gettext = function(text) {
543-
return text
544-
}
545-
id_counter_value = 0
546-
var id_counter = function() {
547-
id_counter_value = id_counter_value + 1
548-
return id_counter_value
549-
}
550-
551-
var after_release_render = function() {
552-
$('[data-toggle="popover"]').popover()
553-
$('[data-toggle="tooltip"]').tooltip()
554-
555-
$(".extra_view").each(function (index, extra_view) {
556-
var jq_extra_view = $(extra_view)
557-
var extra_data = jq_extra_view.data()["extra"]
558-
jq_extra_view.append(JsonHuman.format(extra_data))
559-
})
560-
}
561-
562-
563-
var env = nunjucks.configure()
564-
// this needs replacing with something readable
565-
env.addFilter('currency', function(number) {
566-
try {
567-
return number.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
568-
} catch (e) {
569-
return ""
570-
}
571-
})
572-
var render_json = function (context) {
573-
context = context || {}
574-
var currentValue = jsonInput.val()
575-
if (!currentValue & jsonInputView()) {
576-
container.html('')
577-
return
578-
}
579-
if (!currentValue) {
580-
container.html('<h1> OCDS Show. </h1> <h4>Please supply either an OCDS release or OCDS record. Use upload file or text input buttons above.</h4>')
581-
return
582-
}
583-
try {
584-
var input = JSON.parse(jsonInput.val())
585-
} catch (e) {
586-
container.html('<h2> Invalid JSON data </h2>')
587-
return
588-
}
589-
input['gettext'] = gettext
590-
input['id_counter'] = id_counter
591-
if (input.hasOwnProperty("records")) {
592-
input.ocids = input.records.map(function (value) {
593-
return value.ocid
594-
})
595-
if (context.id) {
596-
id = context.id
597-
} else if(context.newData) {
598-
id = input.ocids[0]
599-
} else {
600-
id = $('#id-select').val()
601-
}
602-
input['ocid'] = id
603-
var current_record;
604-
input.records.some(function (value) {
605-
if (value.ocid === id) {
606-
current_record = value
607-
return true
608-
}
609-
})
610-
var releaseNumber = context["releaseNumber"] || 0
611-
input['releaseNumber'] = releaseNumber
612-
input['releases'] = current_record.releases
613-
input['releases'].sort(function (a, b) {
614-
if (a.date) {
615-
return a.date.localeCompare( b.date );
616-
}
617-
return -1
618-
});
619-
var prev_release = merge(input.releases.slice(0, releaseNumber))
620-
var current_release = merge(input.releases.slice(0, releaseNumber + 1))
621-
var changes = get_changes(flatten_all(prev_release), flatten_all(current_release))
622-
input['release'] = augment_path(current_release)
623-
var parties = input['release']['parties'] || []
624-
if (!(parties instanceof Array)) {
625-
parties = []
626-
}
627-
input.parties = {}
628-
//input.socialWitness = []
629-
parties.forEach(function (party) {
630-
input.parties[party.id] = party
631-
// if (party.roles && party.roles.indexOf('socialWitness') !== -1) {
632-
// input.socialWitness.push(party)
633-
// }
634-
})
635-
function get_change(obj, field) {
636-
if (!obj) {return}
637-
var path = obj.__path;
638-
if (!path) {return}
639-
var path_list = JSON.parse(path)
640-
if (field) {
641-
path_list.push(field)
642-
}
643-
var full_path = JSON.stringify(path_list)
644-
return changes[full_path]
645-
}
646-
input['get_change'] = get_change
647-
container.empty()
648-
var content = env.render('record_select.html', input);
649-
container.append(content)
650-
var content = env.render('record_release.html', input);
651-
container.append(content)
652-
after_release_render()
653-
} else {
654-
input['releases'].sort(function (a, b) {
655-
if (a.date) {
656-
return a.date.localeCompare( b.date );
657-
}
658-
return -1
659-
});
660-
input.release_ids = input.releases.map(function (value) {
661-
return value.id
662-
})
663-
if (context.id) {
664-
id = context.id
665-
} else if (context.newData) {
666-
id = input.release_ids[0]
667-
} else {
668-
id = $('#id-select').val()
669-
}
670-
var current_release;
671-
input.releases.some(function (value) {
672-
if (value.id === id) {
673-
current_release = value
674-
return true
675-
}
676-
})
677-
container.empty()
678-
input['release'] = current_release
679-
input['release_id'] = id
680-
var parties = input['release']['parties'] || []
681-
if (!(parties instanceof Array)) {
682-
parties = []
683-
}
684-
input.parties = {}
685-
//input.release.socialWitness = []
686-
parties.forEach(function (party) {
687-
input.parties[party.id] = party
688-
// if (party.roles.indexOf('socialWitness') !== -1) {
689-
// input.release.socialWitness.push(party)
690-
// }
691-
})
692-
var content = env.render('release_select.html', input);
693-
container.append(content)
694-
var content = env.render('release.html', input);
695-
container.append(content)
696-
after_release_render()
697-
}
698-
// Shareholder pie chart
699-
var shareholders = $('.shareholders-chart');
700-
if (shareholders.length > 0) {
701-
var data = {
702-
'$schema': 'https://vega.github.io/schema/vega/v3.0.json',
703-
'width': 200,
704-
'height': 200,
705-
'padding': 20,
706-
'autosize': 'pad',
707-
'data': [
708-
{
709-
'name': 'pieChart',
710-
'values': null,
711-
'transform': [
712-
{
713-
'type': 'pie',
714-
'field': 'percent'
715-
}
716-
]
717-
}
718-
],
719-
'scales': [
720-
{
721-
'name': 'color',
722-
'type': 'ordinal',
723-
'domain': {'data': 'pieChart', 'field': 'shareholder'},
724-
'range': {'scheme': 'category20'}
725-
}
726-
],
727-
'marks': [
728-
{
729-
'type': 'arc',
730-
'from': {'data': 'pieChart'},
731-
'encode': {
732-
'enter': {
733-
'fill': {'scale': 'color', 'field': 'shareholder'},
734-
'x': {'signal': 'width / 2', 'value': 'field'},
735-
'y': {'signal': 'height / 2'},
736-
'startAngle': {'field': 'startAngle'},
737-
'endAngle': {'field': 'endAngle'},
738-
'innerRadius': {'value': 60},
739-
'outerRadius': {'signal': 'width / 2'}
740-
}
741-
}
742-
},
743-
{
744-
'type': 'text',
745-
'from': {'data': 'pieChart'},
746-
'encode': {
747-
'enter': {
748-
'x': {'field': {'group': 'width'}, 'mult': 0.5},
749-
'y': {'field': {'group': 'height'}, 'mult': 0.5},
750-
'radius': {'value': 80},
751-
'theta': {'signal': '(datum.startAngle + datum.endAngle)/2'},
752-
'fontSize': {'value': 12},
753-
'fontWeight': {'value': 'bold'},
754-
'fill': {'value': '#444'},
755-
'align': {'value': 'center'},
756-
'baseline': {'value': 'middle'},
757-
'text': {'field': 'percentString'}
758-
}
759-
}
760-
}
761-
],
762-
'legends': [
763-
{
764-
'orient': 'right',
765-
'title': 'Shareholders',
766-
'fill': 'color'
767-
}
768-
]
769-
}
770-
shareholders.each(function() {
771-
var shareData = [];
772-
var shareObj = JSON.parse(this.dataset.shareholdersChart);
773-
shareObj.forEach(function(shareholder) {
774-
775-
shareData.push({
776-
'percent': shareholder.shareholding,
777-
'percentString': (shareholder.shareholding * 100) + '%',
778-
"shareholder": shareholder.shareholder.name + ' (' + shareholder.shareholder.id + ')'
779-
})
780-
});
781-
data.data[0].values = shareData;
782-
var view = new vega.View(vega.parse(data))
783-
.renderer('canvas')
784-
.initialize(this)
785-
.hover()
786-
.run();
787-
})
788-
}
789-
}
790-
function getUrlVars()
791-
{
792-
var vars = [], hash;
793-
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
794-
for(var i = 0; i < hashes.length; i++)
795-
{
796-
hash = hashes[i].split('=');
797-
vars.push(hash[0]);
798-
vars[hash[0]] = hash[1];
799-
}
800-
return vars;
801-
}
802-
803-
render_json({"newData": true});
804-
$('#input-json').on("input", function(e) {
805-
render_json({"newData": true});
806-
})
807-
$('#container').on("click", ".release-button", function(e) {
808-
e.preventDefault()
809-
render_json({"releaseNumber": $(this).data()["releaseNumber"]})
810-
})
811-
$('#hide-input-button').on("click", function(e) {
812-
e.preventDefault()
813-
$("#input-json-container").addClass("hide")
814-
})
815-
$('#text-input').on("click", function(e) {
816-
e.preventDefault()
817-
if (jsonInputView()) {
818-
$("#input-json-container").addClass("hide")
819-
} else {
820-
$("#input-json-container").removeClass("hide")
821-
}
822-
render_json({"newData": true});
823-
})
824-
$('#container').on("click", ".nav a", function(e) {
825-
e.preventDefault()
826-
if (!$(this).parent().hasClass("disabled")) {
827-
$(this).tab('show');
828-
}
829-
})
830-
$('#container').on("change", "#id-select", function(e) {
831-
e.preventDefault()
832-
render_json()
833-
})
834-
</script>
835523
{% endblock extrafooterscript %}

cove_ocds/templates/cove_ocds/explore_record.html

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -175,37 +175,4 @@ <h4 class="panel-title">
175175
</div>
176176
</div><!--End Row -->
177177

178-
179-
{% if ocds_show_data %}
180-
<div class="row">
181-
<div class="col-md-12">
182-
<div class="panel panel-default">
183-
<div class="panel-heading">
184-
<h4 class="panel-title">
185-
{% trans "Explore your data:" %}
186-
</h4>
187-
</div>
188-
<div class="panel-body">
189-
<p>
190-
{% blocktrans %}This section provides a visual representation of the data, use it to check whether the data makes sense in the type of tool a user might use to explore it.{% endblocktrans %}
191-
</p>
192-
<p>
193-
{% blocktrans %}Extensions and additional fields are hidden by default, click the 'Extra fields' buttons or open the 'Extra fields' section to view them.{% endblocktrans %}
194-
</p>
195-
<p>
196-
{% blocktrans %}When viewing an OCDS record, use the numbers at the top of the visualization to browse the change history. New and changed fields are highlighted, use this feature to check whether any fields have changed unexpectedly.{% endblocktrans %}
197-
</p>
198-
<div id="input-json-container" class="hide">
199-
<input id="input-json" name="input-json" value="{{ocds_show_data}}">
200-
</div>
201-
202-
<div id="container">
203-
</div>
204-
<div id="graph"></div>
205-
</div>
206-
</div>
207-
</div>
208-
</div>
209-
{% endif %}
210-
211178
{% endblock %}

0 commit comments

Comments
 (0)