diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php index 57d1d47116..b630b2e982 100644 --- a/app/Factory/TagFactory.php +++ b/app/Factory/TagFactory.php @@ -82,17 +82,12 @@ class TagFactory public function findOrCreate(string $tag): ?Tag { $tag = trim($tag); - if (null === $this->tags) { - $this->tags = $this->user->tags()->get(); - } - /** @var Tag $object */ - foreach ($this->tags as $object) { - if (strtolower($object->tag) === strtolower($tag)) { - return $object; - } + /** @var Tag $dbTag */ + $dbTag = $this->user->tags()->where('tag', $tag)->first(); + if (null !== $tag) { + return $dbTag; } - $newTag = $this->create( [ 'tag' => $tag, @@ -103,7 +98,6 @@ class TagFactory 'zoom_level' => null, ] ); - $this->tags->push($newTag); return $newTag; } diff --git a/app/Helpers/Collection/Category.php b/app/Helpers/Collection/Category.php index ce774387ae..35b5529dd1 100644 --- a/app/Helpers/Collection/Category.php +++ b/app/Helpers/Collection/Category.php @@ -77,7 +77,7 @@ class Category public function getCategories(): Collection { $set = $this->categories->sortBy( - function (CategoryModel $category) { + static function (CategoryModel $category) { return $category->spent; } ); diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index ac09787506..8bde0b15aa 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -387,6 +387,10 @@ class CurrencyController extends Controller /** @var User $user */ $user = auth()->user(); $data = $request->getCurrencyData(); + + if (false === $data['enabled'] && $this->repository->currencyInUse($currency)) { + $data['enabled'] = true; + } if (!$this->userRepository->hasRole($user, 'owner')) { // @codeCoverageIgnoreStart $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')])); diff --git a/app/Http/Controllers/Json/AutoCompleteController.php b/app/Http/Controllers/Json/AutoCompleteController.php index 2bce8f12c9..26ee4b2b68 100644 --- a/app/Http/Controllers/Json/AutoCompleteController.php +++ b/app/Http/Controllers/Json/AutoCompleteController.php @@ -68,7 +68,7 @@ class AutoCompleteController extends Controller $filteredAccountTypes[] = $type; } } - Log::debug('Now in accounts(). Filtering results.', $filteredAccountTypes); + Log::debug(sprintf('Now in accounts("%s"). Filtering results.', $search), $filteredAccountTypes); $return = []; $result = $repository->searchAccount((string)$search, $filteredAccountTypes); @@ -107,7 +107,7 @@ class AutoCompleteController extends Controller // filter the account types: $allowedAccountTypes = [AccountType::REVENUE]; - Log::debug('Now in accounts(). Filtering results.', $allowedAccountTypes); + Log::debug('Now in revenueAccounts(). Filtering results.', $allowedAccountTypes); $return = []; $result = $repository->searchAccount((string)$search, $allowedAccountTypes); @@ -138,7 +138,7 @@ class AutoCompleteController extends Controller // filter the account types: $allowedAccountTypes = [AccountType::EXPENSE]; - Log::debug('Now in accounts(). Filtering results.', $allowedAccountTypes); + Log::debug(sprintf('Now in expenseAccounts(%s). Filtering results.', $search), $allowedAccountTypes); $return = []; $result = $repository->searchAccount((string)$search, $allowedAccountTypes); diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index b186248d12..e8eb2aa296 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -83,7 +83,7 @@ class SearchController extends Controller */ public function search(Request $request, SearchInterface $searcher): JsonResponse { - $fullQuery = (string)$request->get('query'); + $fullQuery = (string)$request->get('search'); $searcher->parseQuery($fullQuery); $searcher->setLimit((int)config('firefly.search_result_limit')); diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index 91728c6dc0..449ac9aeab 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -34,6 +34,7 @@ use FireflyIII\Models\ImportJob; use FireflyIII\Models\Preference; use FireflyIII\Models\Rule; use FireflyIII\Models\TransactionGroup; +use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; @@ -568,22 +569,29 @@ class ImportArrayStorage $tag = $repository->store($data); Log::debug(sprintf('Created tag #%d ("%s")', $tag->id, $tag->tag)); - Log::debug('Looping journals...'); - $journalIds = $collection->pluck('id')->toArray(); - $tagId = $tag->id; - foreach ($journalIds as $journalId) { - Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId)); - // @codeCoverageIgnoreStart - try { - DB::table('tag_transaction_journal')->insert(['transaction_journal_id' => $journalId, 'tag_id' => $tagId]); - } catch (QueryException $e) { - Log::error(sprintf('Could not link journal #%d to tag #%d because: %s', $journalId, $tagId, $e->getMessage())); - Log::error($e->getTraceAsString()); - } - // @codeCoverageIgnoreEnd - } - Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $collection->count(), $tag->id, $tag->tag)); + Log::debug('Looping groups...'); + // TODO double loop. + + /** @var TransactionGroup $group */ + foreach ($collection as $group) { + Log::debug(sprintf('Looping journals in group #%d', $group->id)); + /** @var TransactionJournal $journal */ + $journalIds = $group->transactionJournals->pluck('id')->toArray(); + $tagId = $tag->id; + foreach ($journalIds as $journalId) { + Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId)); + // @codeCoverageIgnoreStart + try { + DB::table('tag_transaction_journal')->insert(['transaction_journal_id' => $journalId, 'tag_id' => $tagId]); + } catch (QueryException $e) { + Log::error(sprintf('Could not link journal #%d to tag #%d because: %s', $journalId, $tagId, $e->getMessage())); + Log::error($e->getTraceAsString()); + } + // @codeCoverageIgnoreEnd + } + Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $collection->count(), $tag->id, $tag->tag)); + } $this->repository->setTag($this->importJob, $tag); } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index f67ff8ba25..bb612da44c 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -503,6 +503,7 @@ class BudgetRepository implements BudgetRepositoryInterface public function getBudgetPeriodReport(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array { $carbonFormat = Navigation::preferredCarbonFormat($start, $end); + $data = []; // prep data array: /** @var Budget $budget */ @@ -517,7 +518,6 @@ class BudgetRepository implements BudgetRepositoryInterface // get all transactions: /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts($accounts)->setRange($start, $end); $collector->setBudgets($budgets); $journals = $collector->getExtractedJournals(); @@ -529,7 +529,6 @@ class BudgetRepository implements BudgetRepositoryInterface $date = $journal['date']->format($carbonFormat); $data[$budgetId]['entries'][$date] = bcadd($data[$budgetId]['entries'][$date] ?? '0', $journal['amount']); } - return $data; } diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index 4256266dd6..0091587cc9 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -25,9 +25,12 @@ namespace FireflyIII\Repositories\Currency; use Carbon\Carbon; use FireflyIII\Factory\TransactionCurrencyFactory; use FireflyIII\Models\AccountMeta; +use FireflyIII\Models\AvailableBudget; +use FireflyIII\Models\Bill; use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\CurrencyExchangeRate; use FireflyIII\Models\Preference; +use FireflyIII\Models\RecurrenceTransaction; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService; @@ -62,7 +65,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface */ public function countJournals(TransactionCurrency $currency): int { - return $currency->transactions()->count(); + return $currency->transactions()->count() + $currency->transactionJournals()->count(); + } /** @@ -75,14 +79,14 @@ class CurrencyRepository implements CurrencyRepositoryInterface Log::debug(sprintf('Now in currencyInUse() for #%d ("%s")', $currency->id, $currency->code)); $countJournals = $this->countJournals($currency); if ($countJournals > 0) { - Log::debug(sprintf('Count journals is %d, return true.', $countJournals)); + Log::info(sprintf('Count journals is %d, return true.', $countJournals)); return true; } // is the only currency left if (1 === $this->getAll()->count()) { - Log::debug('Is the last currency in the system, return true. ', $countJournals); + Log::info('Is the last currency in the system, return true. '); return true; } @@ -90,7 +94,41 @@ class CurrencyRepository implements CurrencyRepositoryInterface // is being used in accounts: $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string)$currency->id))->count(); if ($meta > 0) { - Log::debug(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); + Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); + + return true; + } + + // is being used in bills: + $bills = Bill::where('transaction_currency_id', $currency->id)->count(); + if ($bills > 0) { + Log::info(sprintf('Used in %d bills as currency, return true. ', $bills)); + + return true; + } + + // is being used in recurring transactions + $recurringAmount = RecurrenceTransaction::where('transaction_currency_id', $currency->id)->count(); + $recurringForeign = RecurrenceTransaction::where('foreign_currency_id', $currency->id)->count(); + + if ($recurringAmount > 0 || $recurringForeign > 0) { + Log::info(sprintf('Used in %d recurring transactions as (foreign) currency id, return true. ', $recurringAmount + $recurringForeign)); + + return true; + } + + // is being used in accounts (as integer) + $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((int)$currency->id))->count(); + if ($meta > 0) { + Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); + + return true; + } + + // is being used in available budgets + $availableBudgets = AvailableBudget::where('transaction_currency_id', $currency->id)->count(); + if ($availableBudgets > 0) { + Log::info(sprintf('Used in %d available budgets as currency, return true. ', $availableBudgets)); return true; } @@ -98,7 +136,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface // is being used in budget limits $budgetLimit = BudgetLimit::where('transaction_currency_id', $currency->id)->count(); if ($budgetLimit > 0) { - Log::debug(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit)); + Log::info(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit)); return true; } @@ -106,19 +144,19 @@ class CurrencyRepository implements CurrencyRepositoryInterface // is the default currency for the user or the system $defaultCode = app('preferences')->getForUser($this->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data; if ($currency->code === $defaultCode) { - Log::debug('Is the default currency of the user, return true.'); + Log::info('Is the default currency of the user, return true.'); return true; } // is the default currency for the system - $defaultSystemCode = config('firefly.default_currency', 'EUR'); - $result = $currency->code === $defaultSystemCode; - if (true === $result) { - Log::debug('Is the default currency of the SYSTEM, return true.'); - - return true; - } + // $defaultSystemCode = config('firefly.default_currency', 'EUR'); + // $result = $currency->code === $defaultSystemCode; + // if (true === $result) { + // Log::info('Is the default currency of the SYSTEM, return true.'); + // + // return true; + // } Log::debug('Currency is not used, return false.'); return false; diff --git a/app/Services/Spectre/Request/ListLoginsRequest.php b/app/Services/Spectre/Request/ListLoginsRequest.php index d52308ae8e..8062ef1da6 100644 --- a/app/Services/Spectre/Request/ListLoginsRequest.php +++ b/app/Services/Spectre/Request/ListLoginsRequest.php @@ -73,7 +73,7 @@ class ListLoginsRequest extends SpectreRequest } // sort logins by date created: $sorted = $collection->sortByDesc( - function (Login $login) { + static function (Login $login) { return $login->getUpdatedAt()->timestamp; } ); diff --git a/app/Support/Http/Controllers/BasicDataSupport.php b/app/Support/Http/Controllers/BasicDataSupport.php index 5779774352..ea627dde8c 100644 --- a/app/Support/Http/Controllers/BasicDataSupport.php +++ b/app/Support/Http/Controllers/BasicDataSupport.php @@ -53,7 +53,6 @@ trait BasicDataSupport unset($data[$entryId]); } } - return $data; } diff --git a/app/Support/Import/Routine/File/AssetAccountMapper.php b/app/Support/Import/Routine/File/AssetAccountMapper.php index 800ee89ebd..4c0e472b35 100644 --- a/app/Support/Import/Routine/File/AssetAccountMapper.php +++ b/app/Support/Import/Routine/File/AssetAccountMapper.php @@ -31,6 +31,7 @@ use Log; /** * Class AssetAccountMapper + * Can also handle liability accounts. */ class AssetAccountMapper { @@ -41,6 +42,17 @@ class AssetAccountMapper /** @var User */ private $user; + /** @var array */ + private $types; + + /** + * AssetAccountMapper constructor. + */ + public function __construct() + { + $this->types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]; + } + /** * Based upon data in the importable, try to find or create the asset account account. * @@ -56,12 +68,12 @@ class AssetAccountMapper if ((int)$accountId > 0) { // find asset account with this ID: $result = $this->repository->findNull($accountId); - if (null !== $result && $result->accountType->type === AccountType::ASSET) { - Log::debug(sprintf('Found asset account "%s" based on given ID %d', $result->name, $accountId)); + if (null !== $result && in_array($result->accountType->type, $this->types, true)) { + Log::debug(sprintf('Found %s "%s" based on given ID %d', $result->accountType->type, $result->name, $accountId)); return $result; } - if (null !== $result && $result->accountType->type !== AccountType::ASSET) { + if (null !== $result && in_array($result->accountType->type, $this->types, true)) { Log::warning( sprintf('Found account "%s" based on given ID %d but its a %s, return nothing.', $result->name, $accountId, $result->accountType->type) ); @@ -76,8 +88,8 @@ class AssetAccountMapper Log::debug(sprintf('Array does not contain a value for %s. Continue', $field)); continue; } - $result = $this->repository->$function($value, [AccountType::ASSET]); - Log::debug(sprintf('Going to run %s() with argument "%s" (asset account)', $function, $value)); + $result = $this->repository->$function($value, $this->types); + Log::debug(sprintf('Going to run %s() with argument "%s" (asset account or liability)', $function, $value)); if (null !== $result) { Log::debug(sprintf('Found asset account "%s". Return it!', $result->name)); diff --git a/app/Support/Import/Routine/File/ImportableConverter.php b/app/Support/Import/Routine/File/ImportableConverter.php index 002f2131f7..dd09471b85 100644 --- a/app/Support/Import/Routine/File/ImportableConverter.php +++ b/app/Support/Import/Routine/File/ImportableConverter.php @@ -228,19 +228,12 @@ class ImportableConverter { $type = 'unknown'; - if ($source === AccountType::ASSET && $destination === AccountType::ASSET) { - Log::debug('Source and destination are asset accounts. This is a transfer.'); - $type = 'transfer'; - } - if ($source === AccountType::REVENUE) { - Log::debug('Source is a revenue account. This is a deposit.'); - $type = 'deposit'; - } - if ($destination === AccountType::EXPENSE) { - Log::debug('Destination is an expense account. This is a withdrawal.'); - $type = 'withdrawal'; - } + $newType = config(sprintf('firefly.account_to_transaction.%s.%s', $source, $destination)); + if (null !== $newType) { + Log::debug(sprintf('Source is %s, destination is %s, so this is a %s.', $source, $destination, $newType)); + return (string)$newType; + } return $type; } diff --git a/app/Support/Import/Routine/File/OpposingAccountMapper.php b/app/Support/Import/Routine/File/OpposingAccountMapper.php index 497b9d2e1e..36fe9e5dd6 100644 --- a/app/Support/Import/Routine/File/OpposingAccountMapper.php +++ b/app/Support/Import/Routine/File/OpposingAccountMapper.php @@ -60,15 +60,19 @@ class OpposingAccountMapper Log::debug(sprintf('Because amount is %s, will instead search for accounts of type %s', $amount, $expectedType)); } + // append expected types with liability types: + $expectedTypes = [$expectedType, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]; + + if ((int)$accountId > 0) { // find any account with this ID: $result = $this->repository->findNull($accountId); - if (null !== $result && ($result->accountType->type === $expectedType || $result->accountType->type === AccountType::ASSET)) { + if (null !== $result && (in_array($result->accountType->type, $expectedTypes, true) || $result->accountType->type === AccountType::ASSET)) { Log::debug(sprintf('Found account "%s" (%s) based on given ID %d. Return it!', $result->name, $result->accountType->type, $accountId)); return $result; } - if (null !== $result && $result->accountType->type !== $expectedType) { + if (null !== $result && !in_array($result->accountType->type, $expectedTypes, true)) { Log::warning( sprintf( 'Found account "%s" (%s) based on given ID %d, but need a %s. Return nothing.', $result->name, $result->accountType->type, $accountId, @@ -90,7 +94,7 @@ class OpposingAccountMapper } // first search for $expectedType, then find asset: - $searchTypes = [$expectedType, AccountType::ASSET]; + $searchTypes = [$expectedType, AccountType::ASSET, AccountType::DEBT, AccountType::MORTGAGE, AccountType::LOAN]; foreach ($searchTypes as $type) { // find by (respectively): // IBAN, accountNumber, name, diff --git a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php index 5b2341f217..7bc0552663 100644 --- a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php +++ b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php @@ -174,35 +174,33 @@ class StageImportDataHandler } $entry = [ - 'type' => $type, - 'date' => $transaction->getMadeOn()->format('Y-m-d'), - 'tags' => $tags, - 'user' => $this->importJob->user_id, - 'notes' => $notes, - - // all custom fields: - 'external_id' => (string)$transaction->getId(), - - // journal data: - 'description' => $transaction->getDescription(), - 'piggy_bank_id' => null, - 'piggy_bank_name' => null, - 'bill_id' => null, - 'bill_name' => null, - 'original-source' => sprintf('spectre-v%s', config('firefly.version')), - // transaction data: 'transactions' => [ [ - 'currency_id' => null, - 'currency_code' => $currencyCode, - 'description' => null, - 'amount' => $amount, - 'budget_id' => null, - 'budget_name' => null, - 'category_id' => null, - 'category_name' => $transaction->getCategory(), - 'source_id' => $source->id, + 'date' => $transaction->getMadeOn()->format('Y-m-d'), + 'tags' => $tags, + 'user' => $this->importJob->user_id, + 'notes' => $notes, + + // all custom fields: + 'external_id' => (string)$transaction->getId(), + + // journal data: + 'description' => $transaction->getDescription(), + 'piggy_bank_id' => null, + 'piggy_bank_name' => null, + 'bill_id' => null, + 'bill_name' => null, + 'original-source' => sprintf('spectre-v%s', config('firefly.version')), + 'type' => $type, + 'currency_id' => null, + 'currency_code' => $currencyCode, + 'amount' => $amount, + 'budget_id' => null, + 'budget_name' => null, + 'category_id' => null, + 'category_name' => $transaction->getCategory(), + 'source_id' => $source->id, 'source_name' => null, 'destination_id' => $destination->id, 'destination_name' => null, diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 7fa8d39cb0..1850087b94 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -25,7 +25,6 @@ namespace FireflyIII\Support; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; -use Log; /** * Class Navigation. @@ -307,16 +306,15 @@ class Navigation $displayFormat = (string)trans('config.year'); } + $begin = clone $start; $entries = []; while ($begin < $end) { $formatted = $begin->format($format); $displayed = $begin->formatLocalized($displayFormat); $entries[$formatted] = $displayed; - $begin->$increment(); } - return $entries; } diff --git a/public/v1/js/app.js b/public/v1/js/app.js index ce3eaade6f..a95fb3cad6 100644 --- a/public/v1/js/app.js +++ b/public/v1/js/app.js @@ -1,57795 +1 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { -/******/ configurable: false, -/******/ enumerable: true, -/******/ get: getter -/******/ }); -/******/ } -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 14); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports) { - -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -// css base code, injected by the css-loader -module.exports = function(useSourceMap) { - var list = []; - - // return the list of modules as css string - list.toString = function toString() { - return this.map(function (item) { - var content = cssWithMappingToString(item, useSourceMap); - if(item[2]) { - return "@media " + item[2] + "{" + content + "}"; - } else { - return content; - } - }).join(""); - }; - - // import a list of modules into the list - list.i = function(modules, mediaQuery) { - if(typeof modules === "string") - modules = [[null, modules, ""]]; - var alreadyImportedModules = {}; - for(var i = 0; i < this.length; i++) { - var id = this[i][0]; - if(typeof id === "number") - alreadyImportedModules[id] = true; - } - for(i = 0; i < modules.length; i++) { - var item = modules[i]; - // skip already imported module - // this implementation is not 100% perfect for weird media query combinations - // when a module is imported multiple times with different media queries. - // I hope this will never occur (Hey this way we have smaller bundles) - if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { - if(mediaQuery && !item[2]) { - item[2] = mediaQuery; - } else if(mediaQuery) { - item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; - } - list.push(item); - } - } - }; - return list; -}; - -function cssWithMappingToString(item, useSourceMap) { - var content = item[1] || ''; - var cssMapping = item[3]; - if (!cssMapping) { - return content; - } - - if (useSourceMap && typeof btoa === 'function') { - var sourceMapping = toComment(cssMapping); - var sourceURLs = cssMapping.sources.map(function (source) { - return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' - }); - - return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); - } - - return [content].join('\n'); -} - -// Adapted from convert-source-map (MIT) -function toComment(sourceMap) { - // eslint-disable-next-line no-undef - var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); - var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; - - return '/*# ' + data + ' */'; -} - - -/***/ }), -/* 1 */ -/***/ (function(module, exports, __webpack_require__) { - -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra - Modified by Evan You @yyx990803 -*/ - -var hasDocument = typeof document !== 'undefined' - -if (typeof DEBUG !== 'undefined' && DEBUG) { - if (!hasDocument) { - throw new Error( - 'vue-style-loader cannot be used in a non-browser environment. ' + - "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment." - ) } -} - -var listToStyles = __webpack_require__(45) - -/* -type StyleObject = { - id: number; - parts: Array -} - -type StyleObjectPart = { - css: string; - media: string; - sourceMap: ?string -} -*/ - -var stylesInDom = {/* - [id: number]: { - id: number, - refs: number, - parts: Array<(obj?: StyleObjectPart) => void> - } -*/} - -var head = hasDocument && (document.head || document.getElementsByTagName('head')[0]) -var singletonElement = null -var singletonCounter = 0 -var isProduction = false -var noop = function () {} -var options = null -var ssrIdKey = 'data-vue-ssr-id' - -// Force single-tag solution on IE6-9, which has a hard limit on the # of