Skip to content

Commit

Permalink
Merge tag 'v0.12.17' into production-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
LocoDelAssembly committed Sep 2, 2020
2 parents b7e955d + 3b63d47 commit fad7294
Show file tree
Hide file tree
Showing 73 changed files with 955 additions and 439 deletions.
48 changes: 47 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,51 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv

\-

## [0.12.17] - 2020-02-02

### Added
- Successfull source destroy message
- Pending - Definition field to BiologicalRelationship model and views [#1672]
- New button to (attempt to) convert verbatim sources to Bibtex via Crossref
- Model methods and attribute to change Source Verbatim to Bibtex [#1673]
- DOMPurify package to sanitize html
- List all Keyword and Topics in smart selector on filter source [#1675]
- Added data links tool in markdown editor (Ctrl/Alt-Shift-L) [#1674]
- Definition field on composer biological relationship task [#1672]

### Changed
- Unified can_destroy/edit methods
- Improved Source autocomplete with metadata/markup [#1681]
- Changed CoLDP download to use Catalog::Nomenclature as name source
- Replace SimpleMDE for EasyMDE
- Sort alphabetically bibliography style list on filter source
- Removed limit of download bibtex on filter source [#1683]
- Disable/enable destroy button from metadata on radial navigator [#1696]

#### Fixed
- Non admins not able to destroy shared data [#1098]
- Pending confirmation: Include original combinations in CoLDP [#1204]
- Pending confirmation: Include forma/variety properly in CoLDP [#1203]
- Docker: Fixed path typo on clean up command
- Tag button on filter source [#1692]
- Overflow in taxon names list in new taxon name [#1688]
- Confidence button overlapped in new combination [#1687]

[#1098]: https://github.com/SpeciesFileGroup/taxonworks/issues/1098
[#1672]: https://github.com/SpeciesFileGroup/taxonworks/issues/1672
[#1673]: https://github.com/SpeciesFileGroup/taxonworks/issues/1673
[#1674]: https://github.com/SpeciesFileGroup/taxonworks/issues/1674
[#1681]: https://github.com/SpeciesFileGroup/taxonworks/issues/1681
[#1203]: https://github.com/SpeciesFileGroup/taxonworks/issues/1203
[#1204]: https://github.com/SpeciesFileGroup/taxonworks/issues/1204
[#1672]: https://github.com/SpeciesFileGroup/taxonworks/issues/1672
[#1675]: https://github.com/SpeciesFileGroup/taxonworks/issues/1675
[#1683]: https://github.com/SpeciesFileGroup/taxonworks/issues/1683
[#1687]: https://github.com/SpeciesFileGroup/taxonworks/issues/1687
[#1688]: https://github.com/SpeciesFileGroup/taxonworks/issues/1688
[#1692]: https://github.com/SpeciesFileGroup/taxonworks/issues/1692
[#1696]: https://github.com/SpeciesFileGroup/taxonworks/issues/1696

## [0.12.16] - 2020-08-24

### Added
Expand Down Expand Up @@ -373,7 +418,8 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv

[#1532]: https://github.com/SpeciesFileGroup/taxonworks/issues/1532

[unreleased]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.12.16...development
[unreleased]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.12.17...development
[0.12.17]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.12.16...v0.12.17
[0.12.16]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.12.15...v0.12.16
[0.12.15]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.12.14...v0.12.15
[0.12.14]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.12.13...v0.12.14
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN apt-get update && \
nodejs \
redis-server libhiredis-dev && \
apt clean && \
rm -rf /var/lip/abpt/lists/* /tmp/* /var/tmp/*
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN locale-gen en_US.UTF-8

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG BUNDLER_WORKERS=1
RUN apt-get update && \
apt-get install -y curl software-properties-common apt-transport-https && \
apt clean && \
rm -rf /var/lip/abpt/lists/* /tmp/* /var/tmp/*
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Update repos
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
Expand All @@ -28,7 +28,7 @@ RUN apt-get update && \
zip \
nodejs && \
apt clean && \
rm -rf /var/lip/abpt/lists/* /tmp/* /var/tmp/*
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install Firefox (for headless feature tests)
RUN curl -sL 'https://download.mozilla.org/?product=firefox-latest&lang=en-US&os=linux64' | \
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/base/dimensions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ $viewport_width: 1024px;
width: 100%;
}

.width-auto {
width: auto !important;
}

.one_tenth_width {
width: 10%;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/biological_relationships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def set_biological_relationship

def biological_relationship_params
params.require(:biological_relationship).permit(
:name, :inverted_name, :is_transitive, :is_reflexive,
:name, :inverted_name, :is_transitive, :is_reflexive, :definition,
biological_relationship_types_attributes: [:id, :_destroy, :type, :biological_property_id],
origin_citation_attributes: [:id, :_destroy, :source_id, :pages]
)
Expand Down
8 changes: 0 additions & 8 deletions app/controllers/concerns/RequestType.rb

This file was deleted.

12 changes: 8 additions & 4 deletions app/controllers/sources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def parse
def update
respond_to do |format|
if @source.update(source_params)
@source.reload
# We go through this dance to handle changing types from verbatim to other
@source = @source.becomes!(@source.type.safe_constantize)
@source.reload # necessary to reload the cached value.
format.html { redirect_to url_for(@source.metamorphosize), notice: 'Source was successfully updated.' }
format.json { render :show, status: :ok, location: @source.metamorphosize }
else
Expand All @@ -122,20 +124,21 @@ def update
def destroy
if @source.destroy
respond_to do |format|
format.html { redirect_to sources_url }
format.html { redirect_to sources_url, notice: "Destroyed source #{@source.cached}" }
format.json { head :no_content }
end
else
respond_to do |format|
format.html { render action: :show, notice: 'failed to destroy the source' }
format.html { render action: :show, notice: 'failed to destroy the source, there is likely data associated with it' }
format.json { render json: @source.errors, status: :unprocessable_entity }
end
end
end

def autocomplete
@term = params.require(:term)
@sources = Queries::Source::Autocomplete.new(
params.require(:term),
@term,
autocomplete_params
).autocomplete
end
Expand Down Expand Up @@ -282,6 +285,7 @@ def source_params
:abstract, :copyright, :language, :stated_year, :verbatim,
:bibtex_type, :day, :year, :isbn, :issn, :verbatim_contents,
:verbatim_keywords, :language_id, :translator, :year_suffix, :url, :type, :style_id,
:convert_to_bibtex,
roles_attributes: [
:id,
:_destroy,
Expand Down
21 changes: 21 additions & 0 deletions app/helpers/sources_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ def source_tag(source)
source.cached ? sanitize(source.cached, tags: ['i']).html_safe : (source.new_record? ? nil : 'ERROR - Source cache not set, please notify admin.')
end

def sources_autocomplete_tag(source, term)
return nil if source.nil?

if term
s = source.cached.gsub(/#{Regexp.escape(term)}/i, "<mark>#{term}</mark>") + ' ' # weee bit simpler
else
s = source.cached + ' '
end

if source.is_in_project?(sessions_current_project_id)
s += ' ' + content_tag(:span, 'in', class: [:feedback, 'feedback-primary', 'feedback-thin'])
c = source.citations.where(project_id: sessions_current_project_id).count
s += ' ' + ( c > 0 ? content_tag(:span, "#{c.to_s}&nbsp;#{'citations'.pluralize(c)}".html_safe, class: [:feedback, 'feedback-secondary', 'feedback-thin']) : '' )
s += ' ' + content_tag(:span, 'doc/pdf', class: [:feedback, 'feedback-success', 'feedback-thin']) if source.documentation.where(project_id: sessions_current_project_id).any?
else
s += ' ' + content_tag(:span, 'out', class: [:feedback, 'feedback-warning', 'feedback-thin'])
end

s.html_safe
end

def source_author_year_tag(source)
if source && source.type == 'Source::Bibtex' && source.author_year.present?
source.author_year
Expand Down
33 changes: 11 additions & 22 deletions app/helpers/workbench/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def edit_object_path(object)
send(edit_object_path_string(object), object)
end

# Determine wether an edit or destroy route exists
# Custom routes can be added per Class by adding
# a corresponding `_string` postfixed method.
# @return String
def edit_object_path_string(object)
default = "edit_#{metamorphosize_if(object).class.base_class.name.underscore}_path"
specific = default + '_string'
Expand All @@ -148,39 +152,28 @@ def edit_object_path_string(object)

# return [Boolean]
# true if there is a route to edit for the object (some objects are not editable, like Tags)
def is_editable?(object)
def has_route_for_edit?(object)
self.respond_to?(edit_object_path_string(object))
end

# return [Boolean]
# true if the current user has permissions to edit the object in question (does not test whether it is actually editable)
def user_can_edit?(object)
# sessions_current_user.is_administrator? || user_is_creator?(object)
# TODO review
true
end

# return [Boolean]
# true if the current user created this object
def user_is_creator?(object)
object.created_by_id == sessions_current_user_id
end
# true if there is a route to edit for the object (some objects are not editable, like Tags)

# return [A tag, nil]
# a link, or disabled link
def edit_object_link(object)
if is_editable?(object) && user_can_edit?(object)
if has_route_for_edit?(object) && object.is_editable?(sessions_current_user)
link_to(content_tag(:span, 'Edit', 'data-icon' => 'edit', class: 'small-icon'), edit_object_path(metamorphosize_if(object)), class: 'navigation-item')
else
content_tag(:div, content_tag(:span, 'Edit', 'data-icon' => 'edit', class: 'small-icon'), class: 'navigation-item disable')
end
end

def destroy_object_link(object)
if (!sessions_current_user.is_administrator?) && (@is_shared_data_model)
content_tag(:div, content_tag(:span, 'Destroy', 'data-icon' => 'trash', class: 'small-icon'), class: 'navigation-item disable')
if object.is_destroyable?(sessions_current_user)
link_to(content_tag(:span, 'Destroy', 'data-icon' => 'trash', class: 'small-icon'), object.metamorphosize, method: :delete, data: {confirm: 'Are you sure?'}, class: 'navigation-item')
else
link_to(content_tag(:span, 'Destroy', 'data-icon' => 'trash', class: 'small-icon'), object.metamorphosize, method: :delete, data: {confirm: 'Are you sure?'}, class: 'navigation-item')
content_tag(:div, content_tag(:span, 'Destroy', 'data-icon' => 'trash', class: 'small-icon'), class: 'navigation-item disable')
end
end

Expand Down Expand Up @@ -224,12 +217,8 @@ def related_data_link_tag(object)
content_tag(:li, link_to('Related data', send(p, object))) if controller.respond_to?(p)
end

def a_to_z_range
('A'..'Z')
end

def a_to_z_links(targets = [])
letters = targets.empty? ? a_to_z_range : a_to_z_range.to_a & targets
letters = targets.empty? ? ('A'..'Z') : ('A'..'Z').to_a & targets
content_tag(:div, class: 'navigation-bar-left', id: 'alphabet_nav') do
content_tag(:ul, class: 'left_justified_navbar context-menu') do
letters.collect{|l| content_tag(:li, link_to("#{l}", "\##{l}")) }.join.html_safe
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/style/filter.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vue-filter-container {
width: 360px;
max-width: 360px;
width: 400px;
max-width: 400px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export default {
tabs: Object.values(Tabs),
config: {
status: false,
toolbar: ['bold', 'italic', 'code', 'heading', '|', 'quote', 'unordered-list', 'ordered-list', '|', 'link', 'table', 'preview'],
spellChecker: false
}
}
Expand Down
66 changes: 57 additions & 9 deletions app/javascript/vue/components/markdown-editor.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<template>
<div id="markdown-editor">
<textarea/>
<div>
<custom-links
v-if="showCustomLinks"
@close="showCustomLinks = false"
@selected="setCustomLink"/>
<div ref="markdown">
<textarea/>
</div>
</div>
</template>

<script>
import SimpleMDE from 'simplemde'
import 'simplemde/dist/simplemde.min.css'
import EasyMDE from 'easymde'
import DOMPurify from 'dompurify'
import 'easymde/dist/easymde.min.css'
import CustomLinks from './markdown/customLinks.vue'
import GetOSKey from 'helpers/getMacKey.js'
export default {
template: '',
components: {
CustomLinks
},
props: {
value: String,
previewClass: String,
Expand All @@ -29,19 +40,34 @@ export default {
return {
clicks: 0,
timerClicks: undefined,
cursorPosition: 0
cursorPosition: 0,
showCustomLinks: false
}
},
mounted () {
this.initialize()
},
methods: {
initialize () {
const configs = {}
const configs = {
renderingConfig: {
sanitizerFunction: (renderedHTML) => DOMPurify.sanitize(renderedHTML)
},
toolbar: ['bold', 'italic', 'code', 'heading', '|', 'quote', 'unordered-list', 'ordered-list', '|', 'link', 'table', 'preview', {
name: 'width-auto',
action: (editor) => {
this.openCustomLinks()
},
icon:'<span class="word-keep-all">Data links</span>',
title: 'Data links'
}]
}
Object.assign(configs, this.configs)
configs.element = configs.element || this.$el.firstElementChild
console.log(configs)
configs.element = configs.element || this.$refs.markdown.firstElementChild
configs.initialValue = configs.initialValue || this.value
this.simplemde = new SimpleMDE(configs)
this.simplemde = new EasyMDE(configs)
this.customShortcuts()
const className = this.previewClass || ''
this.addPreviewClass(className)
this.bindingEvents()
Expand Down Expand Up @@ -78,6 +104,28 @@ export default {
wrapper.nextSibling.className += ` ${className}`
preview.className = `editor-preview ${className}`
wrapper.appendChild(preview)
},
setCustomLink (item) {
var cm = this.simplemde.codemirror
var output = ''
var selectedText = cm.getSelection()
var text = selectedText || item.label
output = `[${text}](${item.link})`
cm.replaceSelection(output)
},
customShortcuts () {
const codemirror = this.simplemde.codemirror
const keys = codemirror.getOption('extraKeys')
const key = GetOSKey().charAt(0).toUpperCase() + GetOSKey().slice(1)
console.log(key)
keys[`Shift-${key}-L`] = () => {
this.openCustomLinks()
}
codemirror.setOption('extraKeys', keys)
},
openCustomLinks () {
this.showCustomLinks = true
}
},
destroyed () {
Expand Down
Loading

0 comments on commit fad7294

Please sign in to comment.