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

Library: date exceptions #151

Merged
merged 1 commit into from
Dec 6, 2018
Merged

Library: date exceptions #151

merged 1 commit into from
Dec 6, 2018

Conversation

rerowep
Copy link
Contributor

@rerowep rerowep commented Dec 5, 2018

  • NEW: add date exceptions in the library JSON schema
  • NEW: update editor to manage library

Co-Authored-by: Bertrand Zuchuat [email protected]
Co-Authored-by: Nicolas Labat <[email protected]
Signed-off-by: Peter Weber [email protected]

How to test:
Run the scripts bootstrap and setup

The library "Bibliothèque cantonale valdôtaine, site de Pont-Saint-Martin"
has predefined exception dates.

  • check detailed library view
  • edit a library and add or change exception dates

@rerowep rerowep requested review from jma, BadrAly and iGormilhit December 5, 2018 08:04
Copy link

@iGormilhit iGormilhit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure that you've thought about the following points, but my comments on the UI are:

  1. On the detailed view, I would put color (X in red, ✔️ in green).
  2. In the exception list view, I wouldn't display "unique", but only if it's yearly, monthly, etc. The interval value isn't easy to understand.
  3. When editing, I couldn't select yearly and put a value. After saving it's always "unique".
  4. Period days → Days period

Otherwise, I find the UI nice to use. Cool.

And, is this PR up to date with the master branch? I don't see the admin layout commit.

Copy link

@BadrAly BadrAly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impossible to add an exception to a library. You can add an exception only for a library that has exceptions.
other than that --- cool raoul

@rerowep rerowep force-pushed the date-exceptions branch 5 times, most recently from dc0688d to 13f95d4 Compare December 6, 2018 09:27
* NEW: add date exceptions in the library JSON schema
* NEW: update editor to manage library

Co-Authored-by: Bertrand Zuchuat <[email protected]>
Co-Authored-by: Nicolas Labat <[email protected]
Signed-off-by: Peter Weber <[email protected]>
@iGormilhit iGormilhit self-requested a review December 6, 2018 09:51
@rerowep rerowep merged commit 6582189 into rero:master Dec 6, 2018
@@ -66,6 +66,16 @@ def save_library(data, record_type, record_class, parent_pid=None):
library = record_class.get_record_by_pid(pid)
library.update(data, dbcommit=False, reindex=False)
else:
if 'opening_hours' not in data:
data['opening_hours'] = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be replaced by a comprehension list such as [{"day": day, "is_open": False, "times": []} for day in ['monday', 'thuesday', etc]]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be deleted with task #743

[bsValue]="bsValue"
[bsConfig]="{ containerClass: 'theme-default' }">
<div class="input-group-append">
<span class="input-group-text" id="basic-addon2" (click)="dp.toggle()">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad id value

onPeriodChange(period) {
this.form.is_period.setValue(period);
if (period) {
for (let i = 0; i < this.form.times.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it means this.form.times = []?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it means count of time in times

}
}

onIsOpenChange(isopen) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed

}

get title() { return this.form.title; }
get is_period() { return this.form.is_period; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_period => isPeriod, if you agree check all the code


sortExceptions() {
this.exception_dates.sort(function(a, b) {
const keyA = new Date(a.start_date);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moment can be used. Something like: return moment(a.start_date).substract(moment(b.start_date))

@rerowep rerowep deleted the date-exceptions branch December 11, 2018 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants