Commit af200d4b authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Pouvoir forcer le reload du popajax au click

bugs
parent 5c6174b2
Loading
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -125,13 +125,14 @@ Options
-------

| Nom (dataset)   | Nom (Json)    | Type    | Valeur par défaut                                        | Description                                                                                                                                               |
|-----------------|----------------|----------|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|-----------------|---------------|---------|----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| url             | url           | string  | undefined ou href (si présent)                           | URL de chargement de la page AJAX                                                                                                                         |
| content         | content       | string  | undefined                                                | contenu (en HTML). si défini alors le chargement ne se fait plus à partir de l'URL (plus d'AJAX à l'affichage)\...                                        |
| submit-event    | submitEvent   | string  | undefined                                                | nom d'un événement à transmettre. L'événement sera lancé si un formulaire est posté à l'intérieur du popover ET que le résultat ne contient aucune erreur |
| submit-close    | submitClose   | boolean | false                                                    | Détermine on doit fermer le popover après le post d'un formulaire sans retour d'erreur                                                                    |
| submit-reload   | submitReload  | boolean | false                                                    | Détermine on doit recharger toute la page après le post d'un formulaire sans retour d'erreur                                                              |
| loading-title   | loadingTitle  | string  | Chargement\...                                           | Titre lorsque le popover est en cours de chargement                                                                                                       |
| forced          | forced        | boolean | false                                                    | Permet de relancer la requête AJAX systématiquement au réaffichage de la popAjax                                                                          |
| loading-content | loadingContent | string  | <div class="loading"></div>                              | Contenu lorsque le popover est en cours de chargement                                                                                                     |
| title           | title         | string  | undefined                                                | Titre à afficher si le contenu issu de la requête ne contient aucun titre à afficher                                                                      |
| confirm         | confirm       | boolean | false                                                    | transforme le popajax en boite de dialogue de confirmation                                                                                                |
+15 −4
Original line number Diff line number Diff line
@@ -965,6 +965,7 @@ $.widget("unicaen.popAjax", {
        submitEvent: undefined,
        submitClose: false,
        submitReload: false,
        forced: false,
        loadingTitle: 'Chargement...',
        loadingContent: '<div class="loading"></div>',
    },
@@ -1036,6 +1037,7 @@ $.widget("unicaen.popAjax", {
            submitEvent: 'submit-event',
            submitClose: 'submit-close',
            submitReload: 'submit-reload',
            forced: 'forced',
            loadingTitle: 'loading-title',
            loadingContent: 'loading-content',
        };
@@ -1061,18 +1063,19 @@ $.widget("unicaen.popAjax", {

        this.ajaxLoaded = true;
        this.setTitle(this.options.loadingTitle);
        this.setContent(this.options.loadingContent);
        this.setContent(this.options.loadingContent, true);
        $.ajax({
            url: this.options.url,
            success: (response) => {
                that.setContent(response);
                that.contentSubmit(that.getPopoverElement().find('.popover-body'));
            }
        });
    },



    setContent: function (content) {
    setContent: function (content, loading) {
        var ct = IntraNavigator.extractTitle(content);

        this.popInstance._config.content = ct.content;
@@ -1082,7 +1085,9 @@ $.widget("unicaen.popAjax", {
            this.setTitle(ct.title);
        }

        if (loading !== true) {
            this._trigger('change', null, this);
        }
    },


@@ -1117,7 +1122,7 @@ $.widget("unicaen.popAjax", {
    show: function (shown) {
        var that = this;

        if (!this.ajaxLoaded && this.options.url) {
        if ((this.options.forced || !this.ajaxLoaded) && this.options.url) {
            if (this.options.confirm) {
                this.setContent(this.makeConfirmBox());
            } else {
@@ -1152,6 +1157,12 @@ $.widget("unicaen.popAjax", {



    hasErrors: function () {
        return IntraNavigator.hasErrors(this.getContent());
    },



    contentSubmit: function (element) {
        /* Gestion des événements lors de la submition d'un formulaire */
        if (IntraNavigator.hasErrors(element)) {