Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added prefix+suffix-functionality and allow id-fields #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ COFFEE_FILES = \
src/webfrontend/BarcodeEditorPlugin.coffee \
src/webfrontend/BarcodeSearchExpertPlugin.coffee

SCSS_FILES = src/webfrontend/scss/easydb-barcode-display.scss

all: build

include $(EASYDB_LIB)/tools/base-plugins.make
Expand All @@ -35,10 +33,14 @@ ${JS}: $(THIRDPARTY_FILES) $(subst .coffee,.coffee.js,${COFFEE_FILES})
mkdir -p $(dir $@)
cat $^ > $@

build: code $(L10N) css buildinfojson
build: code $(L10N) copycss buildinfojson

code: $(JS) $(THIRDPARTY_FILES)

clean: clean-base

wipe: wipe-base

copycss:
mkdir -p build/webfrontend
cp src/webfrontend/css/easydb-barcode-display.css build/webfrontend/easydb-barcode-display.css
6 changes: 5 additions & 1 deletion l10n/easydb-barcode-display.csv
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ barcode.mask.splitter.option.barcode_type,Barcode-Typ: %(value)s,FALSE,Barcode t
barcode.mask.splitter.option.blockWidth,%(value)s breit,FALSE,%(value)s width,FALSE,%(value)s width,FALSE,%(value)s leveys,FALSE,%(value)s bredd,FALSE,,FALSE,,FALSE,,FALSE
barcode.mask.splitter.option.code_type,Typ: %(value)s,FALSE,Type: %(value)s,FALSE,Type: %(value)s,FALSE,Tyyppi: %(value)s,FALSE,Typ: %(value)s,FALSE,,FALSE,,FALSE,,FALSE
barcode.mask.splitter.option.field_name,Feld: %(value)s,FALSE,Field: %(value)s,FALSE,Field: %(value)s,FALSE,Kenttä: %(value)s,FALSE,Fält: %(value)s,FALSE,,FALSE,,FALSE,,FALSE
barcode.mask.splitter.title|text,Barcode,FALSE,Barcode,FALSE,Barcode,FALSE,Viivakoodi,FALSE,Streckkod,FALSE,,FALSE,,FALSE,,FALSE
barcode.mask.splitter.title|text,Barcode,FALSE,Barcode,FALSE,Barcode,FALSE,Viivakoodi,FALSE,Streckkod,FALSE,,FALSE,,FALSE,,FALSE
barcode.custom.splitter.options.code_prefix.label,Präfix,Prefix,Prefix,Prefix,Prefix,Prefix,Prefix,Prefix
barcode.custom.splitter.options.code_prefix.hint,Wird vor dem Wert eingefügt,Is inserted before value,Is inserted before value,Is inserted before value,Is inserted before value,Is inserted before value,Is inserted before value
barcode.custom.splitter.options.code_suffix.label,Suffix,Suffix,Suffix,Suffix,Suffix,Suffix,Suffix,Suffix
barcode.custom.splitter.options.code_suffix.hint,Wird nach dem Wert eingefügt,Is inserted after value,Is inserted after value,Is inserted after value,Is inserted after value,Is inserted after value,Is inserted after value
Empty file modified src/webfrontend/Barcode.coffee
100644 → 100755
Empty file.
Empty file modified src/webfrontend/BarcodeEditorPlugin.coffee
100644 → 100755
Empty file.
228 changes: 129 additions & 99 deletions src/webfrontend/BarcodeMaskSplitter.coffee
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,114 +1,144 @@
class ez5.BarcodeMaskSplitter extends CustomMaskSplitter

isSimpleSplit: ->
return true
isSimpleSplit: ->
return true

renderAsField: ->
return true
renderAsField: ->
return true

getOptions: ->
fieldSelectorOpts =
store_value: "name"
filter: (field) =>
if not @father.children.some((_field) => _field.getData().field_name == field.name())
return false
return true
fields = ez5.BarcodeMaskSplitter.getBarcodeOptions(@maskEditor.getMask().getTable().table_id, fieldSelectorOpts)
fields.push
type: CUI.NumberInput
form: label: $$("barcode.custom.splitter.options.expert_search_limit.label")
name: "expert_search_limit"
decimals: 0
return fields
getOptions: ->
fieldSelectorOpts =
store_value: "name"
filter: (field) =>
if not @father.children.some((_field) => _field.getData().field_name == field.name())
return false
return true
fields = ez5.BarcodeMaskSplitter.getBarcodeOptions(@maskEditor.getMask().getTable().table_id, fieldSelectorOpts)
fields.push
type: CUI.NumberInput
form: label: $$("barcode.custom.splitter.options.expert_search_limit.label")
name: "expert_search_limit"
decimals: 0
return fields

@getBarcodeOptions: (idObjecttype, fieldSelectorOptions = {}) ->
disableEnableBarcodeType = (field) ->
form = field.getForm()
data = form.getData()
barcodeTypeField = form.getFieldsByName("barcode_type")[0]
if data.code_type == ez5.Barcode.TYPE_BAR
barcodeTypeField.enable()
else
barcodeTypeField.disable()
return
@getBarcodeOptions: (idObjecttype, fieldSelectorOptions = {}) ->
disableEnableBarcodeType = (field) ->
form = field.getForm()
data = form.getData()
barcodeTypeField = form.getFieldsByName("barcode_type")[0]
if data.code_type == ez5.Barcode.TYPE_BAR
barcodeTypeField.enable()
else
barcodeTypeField.disable()
return

fieldSelectorFilter = fieldSelectorOptions.filter
fieldSelectorFilter = fieldSelectorOptions.filter

fieldSelector = new ez5.FieldSelector
form: label: $$("barcode.custom.splitter.options.field-selector.label")
name: "field_name"
store_value: fieldSelectorOptions.store_value or "name"
placeholder: $$("barcode.custom.splitter.options.field-selector.placeholder")
objecttype_id: idObjecttype
schema: "HEAD"
filter: (field) =>
if fieldSelectorFilter and not fieldSelectorFilter?(field)
return false
fieldSelector = new ez5.FieldSelector
form: label: $$("barcode.custom.splitter.options.field-selector.label")
name: "field_name"
store_value: fieldSelectorOptions.store_value or "name"
placeholder: $$("barcode.custom.splitter.options.field-selector.placeholder")
objecttype_id: idObjecttype
schema: "HEAD"
filter: (field) =>

# allow uuid, systemobjectid and globalobjectid
if field.isTopLevelField()
if field instanceof SystemObjectIdColumn or
field instanceof UuidColumn
return true

# beyond that allow only simple text-fields on toplevel
if fieldSelectorFilter and not fieldSelectorFilter?(field)
return false

return field instanceof TextColumn and
field not instanceof DecimalColumn and
field not instanceof LinkColumn and
field not instanceof PrimaryKeyColumn and
field not instanceof LocaTextColumn and
field not instanceof TextMultiColumn and
not field.isTopLevelField()
return field instanceof TextColumn and
field not instanceof DecimalColumn and
field not instanceof LinkColumn and
field not instanceof PrimaryKeyColumn and
field not instanceof LocaTextColumn and
field not instanceof TextMultiColumn and
not field.isTopLevelField()

[
type: CUI.Select
name: "code_type"
form: label: $$("barcode.custom.splitter.options.code-type.label")
options: [
text: $$("barcode.custom.splitter.options.code-type.barcode.text")
value: ez5.Barcode.TYPE_BAR
,
text: $$("barcode.custom.splitter.options.code-type.qrcode.text")
value: ez5.Barcode.TYPE_QR
]
onDataChanged: (_, field) ->
disableEnableBarcodeType(field)
,
type: CUI.Select
name: "barcode_type"
form:
label: $$("barcode.custom.splitter.options.barcode-type.label")
hint: $$("barcode.custom.splitter.options.barcode-type.hint")
onRender: (field) ->
disableEnableBarcodeType(field)
options: ->
options = []
# Barcodes available https://github.com/lindell/JsBarcode/wiki#barcodes
for option in [ez5.Barcode.DEFAULT_BARCODE_TYPE, "CODE39", "ITF14", "MSI", "pharmacode", "codabar", "EAN13", "UPC", "EAN8", "EAN5", "EAN2"]
options.push(value: option)
return options
,
fieldSelector
]
[
type: CUI.Select
name: "code_type"
form: label: $$("barcode.custom.splitter.options.code-type.label")
options: [
text: $$("barcode.custom.splitter.options.code-type.barcode.text")
value: ez5.Barcode.TYPE_BAR
,
text: $$("barcode.custom.splitter.options.code-type.qrcode.text")
value: ez5.Barcode.TYPE_QR
]
onDataChanged: (_, field) ->
disableEnableBarcodeType(field)
,
type: CUI.Select
name: "barcode_type"
form:
label: $$("barcode.custom.splitter.options.barcode-type.label")
hint: $$("barcode.custom.splitter.options.barcode-type.hint")
onRender: (field) ->
disableEnableBarcodeType(field)
options: ->
options = []
# Barcodes available https://github.com/lindell/JsBarcode/wiki#barcodes
for option in [ez5.Barcode.DEFAULT_BARCODE_TYPE, "CODE39", "ITF14", "MSI", "pharmacode", "codabar", "EAN13", "UPC", "EAN8", "EAN5", "EAN2"]
options.push(value: option)
return options
,
type: CUI.Input
name: "code_prefix"
form:
label: $$("barcode.custom.splitter.options.code_prefix.label")
hint: $$("barcode.custom.splitter.options.code_prefix.hint")
,
fieldSelector
,
type: CUI.Input
name: "code_suffix"
form:
label: $$("barcode.custom.splitter.options.code_suffix.label")
hint: $$("barcode.custom.splitter.options.code_suffix.hint")
]

renderField: (opts) ->
fieldName = @getDataOptions().field_name
if not fieldName # Not configured.
return
renderField: (opts) ->
fieldName = @getDataOptions().field_name
if not fieldName # Not configured.
return

if fieldName in ['_uuid', '_system_object_id', '_global_object_id']
_data = opts.top_level_data
data = _data[fieldName]
else
_data = opts.data
data = _data[fieldName]

# add prefix and suffix if given
if @.opts?.options?.code_prefix
data = @.opts.options.code_prefix + data
if @.opts?.options?.code_suffix
data = data + @.opts.options.code_suffix

barcode = new ez5.Barcode
type: @getDataOptions().code_type
barcode_type: @getDataOptions().barcode_type
mode: opts.mode
barcode.render(data)

_data = opts.data
data = _data[fieldName]
hasContent: (opts) ->
fieldName = @getDataOptions().field_name
if not fieldName # Not configured.
return false
data = opts.data[fieldName]
return !!data

barcode = new ez5.Barcode
type: @getDataOptions().code_type
barcode_type: @getDataOptions().barcode_type
mode: opts.mode
barcode.render(data)
_data["#{fieldName}:barcode"] = barcode
return barcode

hasContent: (opts) ->
fieldName = @getDataOptions().field_name
if not fieldName # Not configured.
return false
data = opts.data[fieldName]
return !!data

_data["#{fieldName}:barcode"] = barcode
return barcode

isEnabledForNested: ->
return true
isEnabledForNested: ->
return true

MaskSplitter.plugins.registerPlugin(ez5.BarcodeMaskSplitter)
Empty file modified src/webfrontend/BarcodeSearchExpertPlugin.coffee
100644 → 100755
Empty file.
32 changes: 32 additions & 0 deletions src/webfrontend/css/easydb-barcode-display.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.cui-barcode canvas, .cui-barcode img, .cui-barcode .cui-label {
height: 142px;
width: auto;
max-width: 100%;
object-fit: contain;
object-position: left top;
}
.cui-barcode .cui-label {
max-width: 256px;
}
.cui-barcode--matrix {
max-width: 256px;
}
.cui-barcode--matrix .cui-barcode-ratio {
position: relative;
padding-bottom: 100%;
}
.cui-barcode--matrix canvas, .cui-barcode--matrix img, .cui-barcode--matrix .cui-label {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.cui-barcode--matrix canvas {
display: block !important;
}
.cui-barcode .cui-label {
background: #f4f5f5;
padding: 10px;
}

43 changes: 0 additions & 43 deletions src/webfrontend/scss/easydb-barcode-display.scss

This file was deleted.