Skip to content

Commit

Permalink
Merge branch 'feature/modal-toasts' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
abidibo committed Dec 3, 2020
2 parents 3ffdb50 + 21ccf2a commit 20cbbb5
Show file tree
Hide file tree
Showing 17 changed files with 401 additions and 36 deletions.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Login with user `demo` and password `demo`
- [Menu](#configuration-menu)
- [Analytics](#configuration-analytics)
- [Signals](#signals)
- [Js Utilities](#js-utilities)
- [List Filters](#list-filters)
- [Form Tabs](#form-tabs)
- [Form Includes](#form-includes)
Expand Down Expand Up @@ -304,6 +305,68 @@ To use these, just override the baton `admin/base_site.html` template and regist
</script>
<!-- ... -->

## <a name="js-utilities"></a>Js Utilities

Baton comes with a number of exported js modules you can use to enhance your admin application.

### Dispatcher

Baton Dispatcher singleton module lets you subscribe to event and dispatch them, making use of the Mediator pattern.

Example:

``` javascript

// register a callback tied to the event
Baton.Dispatcher.register('myAppLoaded', function (evtName, s) { console.log('COOL ' + s) })

// emit the event
Baton.Dispatcher.emit('myAppLoaded', 'STUFF!')
```

### Modal

Baton Modal class lets you insert some content on a bootstrap modal without dealing with all the markup.

Usage:

``` javascript
// modal configuration:
//
// let config = {
// title: 'My modal title',
// subtitle: 'My subtitle', // optional
// content: '<p>my html content</p>', // alternative to url
// url: '/my/url', // url used to perform an ajax request, the response is put inside the modal body. Alternative to content.
// hideFooter: false, // optional
// showBackBtn: false, // show a back button near the close icon, optional
// backBtnCb: function () {}, // back button click callback (useful to have a multi step modal), optional
// actionBtnLabel: 'save', // action button label, default 'save', optional
// actionBtnCb: null, // action button callback, optional
// onUrlLoaded: function () {}, // callback called when the ajax request has completed, optional
// size: 'lg', // modal size: sm, md, lg, xl, optional
// onClose: function () {} // callback called when the modal is closed, optional
// }
//
// constructs a new modal instance
// let myModal = new Baton.Modal(config)

let myModal = new Baton.Modal({
title: 'My modal title',
content: '<p>my html content</p>',
size: 'lg'
})

myModal.open();
myModal.close();

myModal.update({
title: 'Step 2',
content: '<p>cool</p>'
})
myModal.toggle();
```

## <a name="list-filters"></a>List Filters

### Input Text Filters
Expand Down
Binary file modified baton/locale/it/LC_MESSAGES/django.mo
Binary file not shown.
69 changes: 43 additions & 26 deletions baton/locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-22 09:11+0200\n"
"POT-Creation-Date: 2020-12-03 16:44+0100\n"
"PO-Revision-Date: 2017-02-12 17:00+0100\n"
"Last-Translator: Stefano Contini <[email protected]>\n"
"Language-Team: it <[email protected]>\n"
Expand All @@ -26,87 +26,104 @@ msgstr "Amministrazione sito"
msgid "Menu"
msgstr "Menu"

#: templates/admin/base_site.html:4
#: templates/admin/base_site.html:5
msgid "Django site admin"
msgstr "Amministrazione sito django"

#: templates/admin/base_site.html:34
#: templates/admin/base_site.html:44
msgid "Django administration"
msgstr "Amministrazione django"

#: templates/admin/input_filter.html:3
#, python-format
msgid " By %(filter_title)s "
msgstr "Per %(filter_title)s"
#: templates/admin/base_site.html:63
msgid "close"
msgstr "chiudi"

#: templates/admin/input_filter.html:18
msgid "Remove"
msgstr "Rimuovi"
#: templates/admin/base_site.html:64
msgid "save"
msgstr "salva"

#: templates/baton/analytics.html:25
#: templates/admin/filer/folder/directory_listing.html:4
msgid "Folders"
msgstr "Cartelle"

#: templates/baton/analytics.html:24
msgid "last 15 days"
msgstr "ultimi 15 giorni"

#: templates/baton/analytics.html:26
#: templates/baton/analytics.html:25
msgid "last month"
msgstr "ultimo mese"

#: templates/baton/analytics.html:27
#: templates/baton/analytics.html:26
msgid "last three months"
msgstr "ultimi tre mesi"

#: templates/baton/analytics.html:28
#: templates/baton/analytics.html:27
msgid "last year"
msgstr "ultimo anno"

#: templates/baton/analytics.html:35
#: templates/baton/analytics.html:34
msgid "Traffic"
msgstr "Traffico"

#: templates/baton/analytics.html:36
#: templates/baton/analytics.html:35
msgid "Sessions and Users"
msgstr "Sessioni e utenti"

#: templates/baton/analytics.html:42
#: templates/baton/analytics.html:41
msgid "Popular"
msgstr "Popolare"

#: templates/baton/analytics.html:43
#: templates/baton/analytics.html:42
msgid "Page views"
msgstr "Visualizzazioni di pagina"

#: templates/baton/analytics.html:51
#: templates/baton/analytics.html:50
msgid "Browsers"
msgstr "Browser"

#: templates/baton/analytics.html:52
#: templates/baton/analytics.html:51
msgid "Top used"
msgstr "Più utilizzati"

#: templates/baton/analytics.html:58
#: templates/baton/analytics.html:57
msgid "Acquisition"
msgstr "Acquisizione"

#: templates/baton/analytics.html:59
#: templates/baton/analytics.html:58
msgid "Referral Traffic"
msgstr "Traffico da ricerca"

#: templates/baton/analytics.html:67
#: templates/baton/analytics.html:66
msgid "Audience"
msgstr "Visitatori"

#: templates/baton/analytics.html:68
#: templates/baton/analytics.html:67
msgid "Countries"
msgstr "Paesi"

#: templates/baton/analytics.html:74
#: templates/baton/analytics.html:73
msgid "Social"
msgstr "Social"

#: templates/baton/analytics.html:75
#: templates/baton/analytics.html:74
msgid "Interactions"
msgstr "Interazioni"

#: templates/baton/filters/dropdown_filter.html:3
#: templates/baton/filters/input_filter.html:3
#, python-format
msgid " By %(filter_title)s "
msgstr "Per %(filter_title)s"

#: templates/baton/filters/input_filter.html:16
msgid "type and press enter..."
msgstr "digita e premi invio..."

#: templates/baton/filters/input_filter.html:20
msgid "Remove"
msgstr "Rimuovi"

#: templates/baton/footer.html:7
msgid "Support"
msgstr "Supporto"
Expand Down
10 changes: 5 additions & 5 deletions baton/static/baton/app/dist/baton.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baton/static/baton/app/dist/baton.min.js.map

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions baton/static/baton/app/src/core/ChangeList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import $ from 'jquery'
import Translator from './i18n'
import Modal from './Modal'

let ChangeList = {
/**
Expand Down Expand Up @@ -37,10 +38,22 @@ let ChangeList = {

if (this.filtersInModal) {
$('#changelist-filter').prop('id', 'changelist-filter-modal')
this.modal = this.createModal()
let titleEl = $('#changelist-filter-modal > h2')
let title = titleEl.html()
titleEl.remove()
let content = $('#changelist-filter-modal')[0].outerHTML
$('#changelist-filter-modal').remove()
this.modal = new Modal({
title,
content,
size: 'md',
hideFooter: true,
})
// this.modal = this.createModal()
_filtersToggler
.click(() => {
this.modal.modal('toggle')
// this.modal.modal('toggle')
this.modal.toggle()
})
} else {
_filtersToggler
Expand Down
Loading

0 comments on commit 20cbbb5

Please sign in to comment.