Browse Source

publish muk_web_utils - 12.0

pull/48/head
MuK IT GmbH 5 years ago
parent
commit
2bb70595eb
  1. 2
      muk_web_utils/__manifest__.py
  2. 82
      muk_web_utils/static/src/js/core/async.js
  3. 1
      muk_web_utils/template/assets.xml

2
muk_web_utils/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Web Utils",
"summary": """Utility Features""",
"version": "12.0.2.8.5",
"version": "12.0.2.8.6",
"category": "Extra Tools",
"license": "AGPL-3",
"author": "MuK IT",

82
muk_web_utils/static/src/js/core/async.js

@ -0,0 +1,82 @@
/**********************************************************************************
*
* Copyright (C) 2017 MuK IT GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
odoo.define('muk_web_utils.async', function (require) {
"use strict";
var core = require('web.core');
var _t = core._t;
var QWeb = core.qweb;
var syncLoop = function(items, func, callback) {
items.reduce(function(promise, item) {
return promise.then(func);
}, $.Deferred().resolve()).then(callback);
};
var syncProgress = function(items, func, callback, update) {
var progress = 0;
items.reduce(function(promise, item) {
return promise.then(function() {
update(++progress / items.length);
return func(item);
});
}, $.Deferred().resolve()).then(callback);
};
var createNotification = function(widget, title) {
return widget.call('notification', 'notify', {
title: title || _t('Upload'),
message: _t('Uploading...'),
icon: 'fa-upload',
sticky: true,
progress: {
text: "0%",
state: 0.0,
},
});
};
var updateNotification = function(widget, notification, progress) {
widget.call('notification', 'progress', notification, {
text: (progress * 100).toFixed(2) + "%",
state: (progress * 100).toFixed(2),
});
};
var closeNotification = function(widget, notification) {
widget.call('notification', 'close', notification);
};
var syncNotification = function(widget, title, items, func, callback) {
var notification = createNotification(widget, title);
var update = _.partial(updateNotification, widget, notification);
syncProgress(items, func, function() {
$.when(closeNotification(widget, notification)).then(callback);
}, update);
};
return {
syncLoop: syncLoop,
syncProgress: syncProgress,
syncNotification: syncNotification,
};
});

1
muk_web_utils/template/assets.xml

@ -34,6 +34,7 @@
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/muk_web_utils/static/src/js/libs/jquery.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/core/utils.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/core/async.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/core/files.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/core/dropzone.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/core/dialog.js" />

Loading…
Cancel
Save