No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Global config for quasar plugin like notify

    Framework
    5
    7
    1672
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      trongdong last edited by

      Hi there,
      First of all, thank you for such a great framework.
      I have a question, when using plugin like Notify, is there a global config or something like that?
      For example, I want to have the notification on on the top right by default.
      So I don’t have to add position to the config object each time we call it.
      Like this:

      this.$q.notify({
         type: "warning",
         message: "Email or password is not correct.",
         position: "top-right"
      });
      

      Thank you very much!

      1 Reply Last reply Reply Quote 0
      • G
        GastroGeek last edited by

        @trongdong

        I have a custom plugin which basically wraps the Notify plugin with some custom config…

        import {
          Notify
        } from 'quasar'
        
        let defaults = {
          color: 'white',
          textColor: 'black',
          timeout: 2000,
          position: 'top'
        }
        
        let notifyInstance = (options) => {
          if (typeof options !== 'object') {
            options = Object.assign({}, defaults, { message: options })
          }
        
          let optionsToUse = Object.assign({}, defaults, options)
        
          return Notify.create(optionsToUse)
        }
        
        export default ({ Vue }) => {
          Vue.prototype.$notify = notifyInstance
        }
        
        export {
          // for use outside components
          notifyInstance as Notify
        }
        
        1 Reply Last reply Reply Quote 0
        • T
          trongdong last edited by

          @GastroGeek Thanks for your help.
          That’s an option but I don’t like that much.
          Do we have an option to load the options with the plugin or something like that should be cleaner?

          G 1 Reply Last reply Reply Quote 0
          • G
            genyded @trongdong last edited by

            @trongdong the Quasar plugins (like Notify, Dialog, etc) initialization is done in the Quasar source code. You should not modify that because updates will overwrite it. The best way is to wrap them as @GastroGeek showed.

            This is true for any plugin like this show for axios https://quasar-framework.org/guide/app-plugins.html#Accessing-data-from-plugins

            1 Reply Last reply Reply Quote 0
            • T
              trongdong last edited by

              @genyded thanks for your clarification.
              If so I think the best scenario is quasar.conf.js come up with some sort of modify plugin’s default value.

              1 Reply Last reply Reply Quote 0
              • nothingismagick
                nothingismagick last edited by

                @GastroGeek is indeed using the right approach here, as things stand in the repo. If you really want to be able to configure it in quasar.conf.js then you should file a feature-request for it at github.

                1 Reply Last reply Reply Quote 0
                • rstoenescu
                  rstoenescu Admin last edited by

                  This is one feature that will land in Quasar v0.16.1 (do not mistake this with CLI version).

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post