Skip to content

Commit

Permalink
fix: many admin issues
Browse files Browse the repository at this point in the history
  • Loading branch information
moogoo78 committed May 23, 2024
1 parent 96bac51 commit a3d66bf
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion app/blueprints/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ def record_list():
per_page = 50 #TODO

# order & limit
stmt = stmt.order_by(desc(Record.id))
#stmt = stmt.order_by(desc(Record.id))
stmt = stmt.order_by(Record.field_number)
if current_page > 1:
stmt = stmt.offset((current_page-1) * per_page)
stmt = stmt.limit(per_page)
Expand Down
12 changes: 9 additions & 3 deletions app/models/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,9 @@ def get_form_layout(self):
}

def get_first_id(self):
if self.identifications:
return self.identifications[0]
ids = self.identifications.all()
if len(ids):
return ids[0]
else:
return None

Expand Down Expand Up @@ -667,9 +668,14 @@ class Unit(Base, TimestampMixin, UpdateMixin):
DISPOSITION_OPTIONS = ["in collection", "missing", "source gone", "voucher elsewhere", "duplicates elsewhere", "consumed"]

ACQUISITION_TYPE_OPTIONS = (
('collecting', '採集'),
('exchange', '交換'),
('gift', '贈送'),
('bequest', '遺贈'),
('purchase', '購買'),
('donation', '捐贈'),
('purchase', '購買'),
('found_in_collection', '其他典藏物件'),

)

TYPE_STATUS_OPTIONS = (
Expand Down
3 changes: 2 additions & 1 deletion app/models/gazetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def __str__(self):

@property
def display_name(self):
return '{}{}'.format(
return '[{}]{}{}'.format(
self.id,
self.name_en if self.name_en else '',
f' ({self.name})' if self.name and self.name.strip() else ''
)
Expand Down
6 changes: 4 additions & 2 deletions app/templates/admin/print-label.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ <h1 class="page-title">page 1</h1>
<div class="locality">
{# if taiwan: show from hsien, else other country, show from province (ex: china) #}
<span class="locality-list">{{ named_areas[1:]|map(attribute='display_name')|join(', ')|replace('TAIWAN (台灣), ', '', 1) }}</span>{# TODO #}
{% if item.record.locality_text or item.record.locality_text_en %}<span class="box">{{ item.record.locality_text }}{% if item.record.locality_text %} ({% endif %}{{ item.record.locality_text_en }}{% if item.record.locality_text %}){% endif %}</span>{% endif %}
{% if item.record.locality_text_en %}<span class="box">{% if not item.record.locality_text %}({% endif %}{{ item.record.locality_text_en }}{% if not item.record.locality_text %}){% endif %}</span>{% endif %}
{% if item.record.locality_text %}<span class="box">{{ item.record.locality_text }}</span>{% endif %}
{% if item.record.locality_text_en %}<span class="box">{{ item.record.locality_text_en }}</span>{% endif %}
{# if item.record.locality_text or item.record.locality_text_en %}<span class="box">{{ item.record.locality_text }}{% if item.record.locality_text %} ({% endif %}{{ item.record.locality_text_en }}{% if item.record.locality_text %}){% endif %}</span>{% endif #}
{# if item.record.locality_text_en %}<span class="box">{% if not item.record.locality_text %}({% endif %}{{ item.record.locality_text_en }}{% if not item.record.locality_text %}){% endif %}</span>{% endif #}
</div>
<div class="geographic-position">
{% set coordinates = item.record.get_coordinates('dms') %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/admin/user-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h3>{{ user_list_categories[cat_id].name }}</h3>
{% for i in user_list_categories[cat_id]['items'] %}
{% set r = i.entity.record %}
<tr>
<td><a href="{{ url_for('admin.record_form', record_id=r.id) }}" uk-icon="icon: pencil"></a></td>
<td><a href="{{ url_for('admin.modify_frontend_collection_record', collection_id=r.collection_id, record_id=r.id ) }}?uid={{ current_user.id }}&uname={{ current_user.username }}" uk-icon="icon: pencil"></a></td>
<td><a href="#" data-user_list_id="{{ i.id }}" uk-icon="icon: trash" class="entity"></a></td>
<td>{{ loop.index }}{# loop.index + (pagination.current_page - 1) * 20 #}</td>
<td>{{ i.entity.unit.accession_number }}</td>
Expand Down
6 changes: 4 additions & 2 deletions client/admin-record/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@
attrs[atype.name] = '';
if (atype.name in unit.assertions) {
let value = unit.assertions[atype.name].value;
console.log(value, atype.name, atype.input_type);
if (atype.input_type === 'select') {
attrs[atype.name] = {text: unit.assevalue, value: value};
attrs[atype.name] = {text: value, value: value};
} else {
attrs[atype.name] = value;
}
Expand All @@ -213,6 +214,7 @@
assertions: attrs,
}
})
console.log(formValues.units);
formValues.named_areas = {};
//formValues.named_areas__admin = $values.named_areas__admin;
for(const [name, data] of Object.entries($values.named_areas)) {
Expand Down Expand Up @@ -967,7 +969,7 @@
{#if $values}
<div class="uk-child-width-expand uk-grid-collapse mg-form-part" uk-grid>
<fieldset>
<legend>鑑定</legend>
<legend>鑒定</legend>
<button class="uk-button uk-button-small uk-button-primary" on:click|preventDefault={addIdentification}>新增</button>
<div class="uk-child-width-1-1 uk-grid-collapse" uk-grid>
{#each formValues.identifications as idObj, idx}
Expand Down
3 changes: 1 addition & 2 deletions client/admin-record/src/lib/AttributeBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
text: 'display_name,'
};
export let initValues = {};
//console.log(initValues);
</script>

{#each attrTypes as atype}
{#if atype.input_type === "select"}
<FormWidget id="" bind:value={values[atype.name]} label={atype.label} type="select" options={atype.options.map( x => {
<FormWidget id="" bind:value={values[atype.name].value} label={atype.label} type="select" options={atype.options.map( x => {
if (Array.isArray(x) && x.length) {
return {text: x[1], value: x[0]};
} else {
Expand Down

0 comments on commit a3d66bf

Please sign in to comment.